【发布时间】:2011-05-29 11:33:19
【问题描述】:
我目前正在处理与 bbPress 的 RTX/Janrain 集成,但我坚持使用 SQL 查询,即使我一直在尝试使用通配符并且我知道已注册的电子邮件地址也没有给我任何结果。
登入
$rpxApiKey = 'xxxxx';
if(isset($_POST['token'])) { /* 第 1 步:提取令牌 POST 参数 */ $token = $_POST['token'];
/* 第 2 步:使用令牌制作 auth_info API 调用 */ $post_data = 数组('token' => $_POST['token'], 'apiKey' => $rpxApiKey, '格式' => 'json');
$curl = curl_init(); curl_setopt($curl, CURLOPT_RETURNTRANSFER,真); 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, 错误的); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER,假); $raw_json = curl_exec($curl); curl_close($curl);/* 第 3 步:解析 JSON auth_info 响应 */ $auth_info = json_decode($raw_json, true);
if ($auth_info['stat'] == 'ok') { /* 第 3 步继续:从响应中提取“标识符”*/ $profile = $auth_info['profile']; $identifier = $profile['标识符'];
$profile['标识符']; if (isset($profile['photo'])) { $photo_url = $profile['照片']; }if (isset($profile['displayName'])) { $name = $profile['displayName']; }if (isset($profile['email'])) { $email = $profile['email']; } /* Step 5, 检查用户是否存在于数据库中,如果存在则登录,如果 不创建新用户然后登录*/ 全局$bbdb; $查询字符串 = " SELECT * FROM $bbdb->bb_users
WHERE user_email = $email LIMIT 1"; $rtx_user_id = $bbdb->get_results($querystr, OBJECT); print_r($rtx_user_id); 如果($rtx_user_id){ echo "大获成功"; wp_set_auth_cookie( (int) $rtx_user_id, 0 ); // 0 = 不要 记住,短登录,待办事项:使用表单 值 do_action('bb_user_login', (int) $rtx_user_id ); } 如果 (!$rtx_user_id) { echo "不好 成功”;}/* STEP 6: Use the identifier as the unique key to sign the user into您的系统。 这将取决于您的网站实施,您应该 添加你自己的 代码在这里。 */
/* 发生错误 */ }
else { // 优雅地处理 错误。将其与您的母语挂钩 错误处理系统。回声'安 发生了错误: ' 。 $auth_info['err']['msg']; } } } ?>
问题出现在第 5 步,即检查用户是否存在。
提前致谢, 貂
【问题讨论】:
标签: php sql janrain bbpress rtx