コード例 #1
0
 public function getInfoAction($token)
 {
     $url = 'https://graph.facebook.com/me?fields=id,name,email,birthday,work,friends&access_token=' . $token;
     $json = StaticClass::getJsonDecodeFromUrl($url);
     dump($json);
     return new Response('');
 }
コード例 #2
0
 /**
  * Generate FacebookUser by token
  *
  * @param string $token
  * @return FacebookUser
  */
 public static function getUserByToken($token)
 {
     //Get user information from facebook graph api
     $url = sprintf(static::FACBOOK_API_GET_BASIC_INFO, $token);
     $arrUser = StaticClass::getJsonDecodeFromUrl($url);
     //Create new FacebookUser
     $facebookUser = new FacebookUser();
     $facebookUser->setIdFacebook($arrUser['id']);
     $facebookUser->setEmail($arrUser['email']);
     $facebookUser->setName($arrUser['name']);
     if (!empty($arrUser['birthday'])) {
         $facebookUser->setBirthday(\DateTime::createFromFormat(Variable::FACEBOOK_DATE_FORMAT, $arrUser['birthday']));
     } else {
         $facebookUser->setBirthday(new \DateTime());
     }
     foreach ($arrUser['friends']['data'] as $friend) {
         $facebookUser->addFacebookFriendIds($friend['id']);
     }
     return $facebookUser;
 }
コード例 #3
0
 /**
  * Convert array user data to LinkedinUser
  *
  * @param string $token
  * @param LinkedinUser|null $user
  * @return LinkedinUser
  */
 private static function getBasicProfile($token, LinkedinUser $user = null)
 {
     //Get information from url
     $strFields = 'id,email-address,firstName,lastName,picture-url,num-connections,siteStandardProfileRequest';
     $url = sprintf(static::LINKEDIN_API_GET_BASIC_INFO, $strFields, $token);
     $options = StaticClass::getJsonDecodeFromUrl($url);
     //Create user if user is null
     if (empty($user)) {
         $user = new LinkedinUser();
     }
     //Set information for user
     $user->setIdLinkedin($options['id']);
     $user->setEmail($options['emailAddress']);
     $user->setFirstName($options['firstName']);
     $user->setLastName($options['lastName']);
     $user->setNumConnections($options['numConnections']);
     $user->setPictureUrl($options['pictureUrl']);
     $user->setPictureUrl($options['pictureUrl']);
     if (!empty($options['siteStandardProfileRequest'])) {
         $user->setSiteUrl($options['siteStandardProfileRequest']['url']);
     }
     return $user;
 }