Example #1
0
 /**
  * Gets the profile of the user who has granted access.
  *
  * @see https://dev.xing.com/docs/get/users/me
  */
 function getUserProfile()
 {
     parent::getUserProfile();
     $oResponse = $this->api->get('users/me');
     // The HTTP status code needs to be 200 here. If it's not, something is wrong.
     if ($this->api->http_code !== 200) {
         throw new \Exception('Profile request failed! ' . (string) $this->providerId . ' API returned an error: ' . $this->errorMessageByStatus($this->api->http_code) . '.');
     }
     // We should have an object by now.
     if (!is_object($oResponse)) {
         throw new \Exception('Profile request failed! ' . (string) $this->providerId . ' API returned an error: invalid response.');
     }
     // Redefine the object.
     $oResponse = $oResponse->users[0];
     $this->user->profile->email = property_exists($oResponse, 'active_email') ? $oResponse->active_email : '';
     if (property_exists($oResponse, 'professional_experience')) {
         $professionalExperience = $oResponse->professional_experience;
         if (property_exists($professionalExperience, 'primary_company')) {
             $primaryCompany = $professionalExperience->primary_company;
             if (property_exists($primaryCompany, 'name')) {
                 $this->user->profile->company = $primaryCompany->name;
             }
             if (property_exists($primaryCompany, 'title')) {
                 $this->user->profile->position = $primaryCompany->title;
             } else {
                 if (property_exists($primaryCompany, 'description')) {
                     $this->user->profile->position = $primaryCompany->description;
                 }
             }
             if (property_exists($primaryCompany, 'industry')) {
                 $this->user->profile->industry = $primaryCompany->industry;
             }
         }
     }
     // We use the largest picture available.
     $requestedPictureSize = \XingUserPicureSize::SIZE_ORIGINAL;
     if (property_exists($oResponse, 'photo_urls') && property_exists($oResponse->photo_urls, $requestedPictureSize)) {
         $this->user->profile->photoURL = property_exists($oResponse->photo_urls, $requestedPictureSize) ? $oResponse->photo_urls->size_original : '';
     }
     return $this->user->profile;
 }
Example #2
0
 function __construct($providerId, $config, $params = NULL)
 {
     parent::__construct($providerId, $config, $params);
     // TODO: Change the autogenerated stub
     $this->user = new PxHybridAuth_Hybrid_User();
 }