コード例 #1
0
 /**
  * Check if ID can be link or not. if yes the link account.
  */
 public static function link_account_if_possible()
 {
     global $loginRadiusObject, $wpdb, $user_ID;
     $loginRadiusMappingData = array();
     if (null == $loginRadiusObject) {
         $loginRadiusObject = new LoginRadius();
     }
     if (isset($_REQUEST['token']) && is_user_logged_in()) {
         try {
             $loginRadiusUserprofile = $loginRadiusObject->loginradius_get_user_profiledata($_REQUEST['token']);
         } catch (LoginRadiusException $e) {
             // Error Handling
             if ($loginRadiusSettings['enable_degugging'] == '0') {
                 // if debugging is off and Social profile not recieved, redirect to home page.
                 wp_redirect(site_url());
                 exit;
             } else {
                 $loginRadiusUserprofile = null;
                 $message = isset($e->getErrorResponse()->description) ? $e->getErrorResponse()->description : $e->getMessage();
                 error_log($message);
                 // If debug option is set and Social Profile not retrieved
                 Login_Helper::login_radius_notify($message, 'isProfileNotRetrieved');
                 return;
             }
         }
         $loginRadiusMappingData['id'] = !empty($loginRadiusUserprofile->ID) ? $loginRadiusUserprofile->ID : '';
         $loginRadiusMappingData['provider'] = !empty($loginRadiusUserprofile->Provider) ? $loginRadiusUserprofile->Provider : '';
         $loginRadiusMappingData['thumbnail'] = !empty($loginRadiusUserprofile->ThumbnailImageUrl) ? trim($loginRadiusUserprofile->ThumbnailImageUrl) : '';
         if (empty($loginRadiusMappingData['thumbnail']) && $loginRadiusMappingData['provider'] == 'facebook') {
             $loginRadiusMappingData['thumbnail'] = 'http://graph.facebook.com/' . $loginRadiusMappingData['id'] . '/picture?type=large';
         }
         $loginRadiusMappingData['pictureUrl'] = !empty($loginRadiusUserprofile->ImageUrl) ? trim($loginRadiusUserprofile->ImageUrl) : '';
         $wp_user_id = $wpdb->get_var($wpdb->prepare('SELECT user_id FROM ' . $wpdb->usermeta . ' WHERE meta_key="loginradius_provider_id" AND meta_value = %s', $loginRadiusMappingData['id']));
         if (!empty($wp_user_id)) {
             // Check if verified field exist or not.
             $loginRadiusVfyExist = $wpdb->get_var($wpdb->prepare('SELECT user_id FROM ' . $wpdb->usermeta . ' WHERE user_id = %d AND meta_key = "loginradius_isVerified"', $wp_user_id));
             if (!empty($loginRadiusVfyExist)) {
                 // if verified field exists
                 $loginRadiusVerify = $wpdb->get_var($wpdb->prepare('SELECT meta_value FROM ' . $wpdb->usermeta . ' WHERE user_id = %d AND meta_key = "loginradius_isVerified"', $wp_user_id));
                 if ($loginRadiusVerify != '1') {
                     self::link_account($user_ID, $loginRadiusMappingData['id'], $loginRadiusMappingData['provider'], $loginRadiusMappingData['thumbnail'], $loginRadiusMappingData['pictureUrl']);
                     return true;
                 } else {
                     //account already mapped
                     return false;
                 }
             } else {
                 return false;
             }
         } else {
             $loginRadiusMappingProvider = $loginRadiusMappingData['provider'];
             $wp_user_lrid = $wpdb->get_var($wpdb->prepare('SELECT user_id FROM ' . $wpdb->usermeta . ' WHERE meta_key="' . $loginRadiusMappingProvider . 'Lrid" AND meta_value = %s', $loginRadiusMappingData['id']));
             if (!empty($wp_user_lrid)) {
                 $lrVerified = get_user_meta($wp_user_lrid, $loginRadiusMappingProvider . 'LrVerified', true);
                 if ($lrVerified == '1') {
                     // Check if lrid is the same that verified email.
                     // account already mapped
                     return false;
                 } else {
                     // map account
                     self::link_account($user_ID, $loginRadiusMappingData['id'], $loginRadiusMappingData['provider'], $loginRadiusMappingData['thumbnail'], $loginRadiusMappingData['pictureUrl']);
                     return true;
                 }
             } else {
                 // map account
                 self::link_account($user_ID, $loginRadiusMappingData['id'], $loginRadiusMappingData['provider'], $loginRadiusMappingData['thumbnail'], $loginRadiusMappingData['pictureUrl']);
                 return true;
             }
         }
     }
 }
コード例 #2
0
ファイル: callback.php プロジェクト: frenzyashru/php-sdk
 $UserSendMessage = '';
 $UserContacts = '';
 $UserMentions = '';
 $UserFollowing = '';
 $UserEvents = '';
 $UserGetPost = '';
 $UserFollowedCompanies = '';
 $UserGroups = '';
 $UserGetStatus = '';
 $UserPostStatus = '';
 $UserVideos = '';
 $UserLikes = '';
 $post_status = '';
 $sendmessage = '';
 try {
     $UserProfileData = $loginradius->loginradius_get_user_profiledata($lraccesstoken);
 } catch (LoginRadiusException $e) {
     echo ' User Profile Data API :- ';
     echo $e->getMessage() . '<br>';
 }
 if (!empty($UserProfileData) && is_object($UserProfileData)) {
     if (in_array($UserProfileData->Provider, array('foursquare'))) {
         try {
             $UserPhotos = $loginradius->loginradius_get_photos($lraccesstoken);
         } catch (LoginRadiusException $e) {
             echo ' Photo API :- ';
             echo $e->getMessage() . '<br>';
         }
     }
     if (in_array($UserProfileData->Provider, array('facebook', 'google', 'live', 'vkontakte', 'renren'))) {
         try {