本文整理匯總了PHP中Facebook\GraphUser::getLink方法的典型用法代碼示例。如果您正苦於以下問題:PHP GraphUser::getLink方法的具體用法?PHP GraphUser::getLink怎麽用?PHP GraphUser::getLink使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Facebook\GraphUser
的用法示例。
在下文中一共展示了GraphUser::getLink方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: createUserProfile
private function createUserProfile(FacebookSession $session, GraphUser $user)
{
$profile = new UserProfile();
$profilePicReq = new FacebookRequest($session, 'GET', '/me/picture', ['redirect' => 0, 'type' => 'large']);
$pic = $profilePicReq->execute()->getGraphObject()->asArray();
$profile['displayName'] = $user->getName();
$profile['profileUrl'] = $user->getLink();
$profile['imageUrl'] = $pic['url'];
//TODO other props
return $profile;
}
示例2: facebookRegister
/**
* Register user using facebook data. It will also check if email already exists and it will update that user.
* @param GraphUser $me
* @return User|null
*/
public static function facebookRegister(GraphUser $me)
{
// 1. check if email already exists.
$old = self::findByAttributes(array('email' => $me->getEmail()));
if ($old) {
/* @var $old User */
$old->fb_id = $me->getId();
if ($old->status == self::STATUS_NEW) {
$old->status = self::STATUS_ACTIVE;
}
$old->save(false);
UserConfig::set('FACEBOOK_NAME', $me->getFirstName() . ' ' . $me->getMiddleName() . ' ' . $me->getLastName(), $old->id);
UserConfig::set('FACEBOOK_EMAIL', $me->getProperty('email'), $old->id);
UserConfig::set('FACEBOOK_PROFILE', $me->getLink(), $old->id);
return $old;
}
$user = new User();
$user->fb_id = $me->getId();
$user->email = $me->getProperty('email');
$user->register_date = date('Y-m-d H:i:s');
$user->status = self::STATUS_ACTIVE;
$user->save(false);
UserConfig::set('FACEBOOK_NAME', $me->getFirstName() . ' ' . $me->getMiddleName() . ' ' . $me->getLastName(), $user->id);
UserConfig::set('FACEBOOK_EMAIL', $me->getProperty('email'), $user->id);
UserConfig::set('FACEBOOK_PROFILE', $me->getLink(), $user->id);
return $user;
}