bbPress RTX 集成

发布于 2024-10-08 12:25:02 字数 2187 浏览 0 评论 0原文

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

登入

$rpxApiKey = 'xxxxx';

if(isset($_POST['token'])) { /* 第 1 步:提取令牌 POST 参数 */ $token = $_POST['token'];

/* 第 2 步:使用令牌来制作 auth_info API 调用 */ $post_data = array('token' => $_POST['token'], 'apiKey' =>; $rpxApiKey, '格式' => 'json');

$curl=curl_init(); 卷曲_setopt($卷曲, 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, 错误的);卷曲_setopt($卷曲, 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'] == '确定') { /* 第 3 步继续:从响应中提取“标识符”*/ $profile = $auth_info['profile']; $identifier = $profile['identifier'];
$个人资料['标识符']; if (isset($profile['照片'])) { $photo_url = $profile['照片']; }

if (isset($profile['displayName'])) {
  $name = $profile['显示名称'];
}

if (isset($profile['email'])) { $email = $profile['email']; } /* 步骤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){ 回声“伟大的成功”; wp_set_auth_cookie( (int) $rtx_user_id, 0 ); // 0 = 不 记住,短登录,待办事项:使用表单 值 do_action('bb_user_login', (int) $rtx_user_id ); } 如果 (!$rtx_user_id) { echo "不太好 成功”;}

/* 第 6 步:使用标识符作为用户登录的唯一密钥

你的系统。 这将取决于您的网站实施,您应该 添加您自己的 代码在这里。 */

/* 发生错误 */ }

else { // 优雅地处理 错误。将其连接到您的本机 错误处理系统。回声安 发生错误:' . $auth_info['err']['msg']; } } } ?>

问题出现在步骤5,即检查用户是否存在。

提前致谢, 貂

Im currently working on a RTX/Janrain integration with bbPress, but im stuck with a SQL query which doesnt give me any results even though I've been trying with wildcards and an e-mail adress i know is registered.

Sign In

$rpxApiKey = 'xxxxx';

if(isset($_POST['token'])) { /*
STEP 1: Extract token POST parameter
*/ $token = $_POST['token'];

/* STEP 2: Use the token to make the
auth_info API call */ $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($curl);

/* STEP 3: Parse the JSON auth_info
response */ $auth_info =
json_decode($raw_json, true);

if ($auth_info['stat'] == 'ok') {
/* STEP 3 Continued: Extract the 'identifier' from the response */
$profile = $auth_info['profile'];
$identifier = $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'];
}
/* Step 5, Check if user existis in database, if so login, if
not create new user then login*/
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 "Great success";
wp_set_auth_cookie( (int) $rtx_user_id, 0 ); // 0 = don't
remember, short login, todo: use form
value do_action('bb_user_login',
(int) $rtx_user_id ); } if
(!$rtx_user_id) { echo "Not great
success";}

/* STEP 6: Use the identifier as the unique key to sign the user into

your system.
This will depend on your website implementation, and you should
add your own
code here.
*/

/* an error occurred */ }

else { // gracefully handle the
error. Hook this into your native
error handling system. echo 'An
error occured: ' .
$auth_info['err']['msg']; } } } ?>

The problem accrues in Step 5 which is to check if the user exists.

Thanks in advance,
Marten

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

海夕 2024-10-15 12:25:02

正如我们在 Twitter 上讨论的那样,查询行应该是

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

As we talked on twitter, the query line should be

$querystr = "SELECT * FROM $bbdb->users WHERE user_email = '$email' LIMIT 1";
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文