Home  >  Article  >  php教程  >  drupal6第三方登录模块

drupal6第三方登录模块

WBOY
WBOYOriginal
2016-06-06 19:37:501700browse

之前用drupal6.19做过一个电商平台,升级重新改版,发现drupal6的第三登录模块还没有,直接把drupal7中开源csna拿过来修改,测试通过。 无 $csna_renren_key = '100?????'; $csna_renren_secret = '??????????';第三方登录申请的KEY值。回调验证后把登录账

之前用drupal6.19做过一个电商平台,升级重新改版,发现drupal6的第三登录模块还没有,直接把drupal7中开源csna拿过来修改,测试通过。
        $csna_renren_key = '100?????';
        $csna_renren_secret = '??????????';
第三方登录申请的KEY值。

回调验证后把登录账号信息写入到数据库中。
function csnaqq_callback($provider)

  if (isset($data['access_token'])) {

		$u_id =urlencode($data["uid"]);
		$u_name = urlencode($data["name"]);
		if(!empty($u_name) && !empty($u_id))
		{
      //判断数据库中的账号是否存在,如果不存在创建新账号,如果账号存在,则登录账号
        $total = db_result(db_query("SELECT COUNT(*) AS total FROM {users} WHERE LOWER(name) = '%s'", strtolower($u_id)));
        if ($total <= 0) {
          db_query("insert into {users} (name,nick_name,login_mode) values('%s','%s',%d)",$u_id,$u_name,4);
        }
        $user_info = array('name' => $u_id);
        $user=user_load($user_info);

        $user->name = $u_name;

        if($total <= 0)
        {
          db_query("insert into {users_roles} (uid,rid) values(%d,%d)",$user->uid,9);
        }
		}
  }
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn