首页 文章

bbPress RTX集成

提问于
浏览
1

我目前正在与bbPress进行RTX / Janrain集成,但我坚持使用SQL查询,即使我一直在尝试使用通配符和我知道已注册的电子邮件地址,但它并没有给我任何结果 .

登录$ rpxApiKey ='xxxxx'; if(isset($ _ POST ['token'])){/ 第1步:提取令牌POST参数 / $ token = $ _POST ['token']; / 步骤2:使用令牌进行auth_info API调用 / $ post_data = array('token'=> $ _POST ['token'],'apiKey'=> $ rpxApiKey,'format'=>'json' ); $ curl = curl_init(); curl_setopt($ curl,CURLOPT_RETURNTRANSFER,true); curl_setopt($ curl,CURLOPT_URL,'https://rpxnow.com/api/v2/auth_info'); curl_setopt($ curl,CURLOPT_POST,true); curl_setopt($ curl,CURLOPT_POSTFIELDS,$ post_data); curl_setopt($ curl,CURLOPT_HEADER,false); curl_setopt($ curl,CURLOPT_SSL_VERIFYPEER,false); $ raw_json = curl_exec($ curl); curl_close($卷曲); / 步骤3:解析JSON auth_info响应 / $ auth_info = json_decode($ raw_json,true); if($ auth_info ['stat'] =='ok'){/ 第3步续:从响应 / $ profile = $ auth_info ['profile']中提取'标识符'; $ identifier = $ profile ['identifier']; $简档[ '标识符']; if(isset($ profile ['photo'])){$ photo_url = $ profile ['photo']; } if(isset($ profile ['displayName'])){
$ name = $ profile ['displayName'];
}
if(isset($ profile ['email'])){$ email = $ profile ['email']; } / 步骤5,检查用户是否存在于数据库中,如果是,则登录,如果没有创建新用户则登录 / global $ bbdb; $ querystr =“SELECT * FROM $ bbdb-> bb_users WHERE user_email = $ email LIMIT 1”; $ rtx_user_id = $ bbdb-> get_results($ querystr,OBJECT);的print_r($ rtx_user_id); if($ rtx_user_id){echo“巨大的成功”; wp_set_auth_cookie((int)$ rtx_user_id,0); // 0 =不记得,短登录,待办事项:使用表单值do_action('bb_user_login',(int)$ rtx_user_id); } if(!$ rtx_user_id){echo“not great success”;} / *步骤6:使用标识符作为唯一键来签署用户
你的系统 . 这取决于您的网站实施,您应该在这里添加自己的代码 . * / / 发生错误 /} else {//正常处理错误 . 将此连接到您的本机错误处理系统 . echo'发生错误:' . $ auth_info [ 'ERR'] [ 'MSG']; }>}

问题在步骤5中产生,即检查用户是否存在 .

提前谢谢,貂

1 回答

  • 2

    正如我们在twitter上谈到的那样,查询行应该是

    $querystr = "SELECT * FROM $bbdb->users WHERE user_email = '$email' LIMIT 1";
    

相关问题