bbPress RTX integration
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 开发者_StackOverflow社区$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
As we talked on twitter, the query line should be
$querystr = "SELECT * FROM $bbdb->users WHERE user_email = '$email' LIMIT 1";
精彩评论