本文整理汇总了PHP中Foreign_link::getProfile方法的典型用法代码示例。如果您正苦于以下问题:PHP Foreign_link::getProfile方法的具体用法?PHP Foreign_link::getProfile怎么用?PHP Foreign_link::getProfile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Foreign_link
的用法示例。
在下文中一共展示了Foreign_link::getProfile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: subscribeTwitterFriends
function subscribeTwitterFriends(Foreign_link $flink)
{
try {
$profile = $flink->getProfile();
} catch (NoResultException $e) {
common_log(LOG_WARNING, 'Foreign_link has no matching local profile for local ID: ' . $flink->user_id);
}
$friends = $this->fetchTwitterFriends($flink);
if (empty($friends)) {
common_debug($this->name() . ' - Couldn\'t get friends from Twitter for ' . "Twitter user {$flink->foreign_id}.");
return false;
}
foreach ($friends as $friend) {
$friend_name = $friend->screen_name;
$friend_id = (int) $friend->id;
// Update or create the Foreign_user record for each
// Twitter friend
if (!save_twitter_user($friend_id, $friend_name)) {
common_log(LOG_WARNING, $this->name() . " - Couldn't save {$screen_name}'s friend, {$friend_name}.");
continue;
}
// Check to see if there's a related local user and try to subscribe
try {
$friend_flink = Foreign_link::getByForeignID($friend_id, TWITTER_SERVICE);
// Get associated user and subscribe her
$friend_profile = $friend_flink->getProfile();
Subscription::start($profile, $friend_profile);
common_log(LOG_INFO, $this->name() . ' - Subscribed ' . "{$friend_profile->nickname} to {$profile->nickname}.");
} catch (NoResultException $e) {
// either no foreign link for this friend's foreign ID or no profile found on local ID.
} catch (Exception $e) {
common_debug($this->name() . ' - Tried and failed subscribing ' . "{$friend_profile->nickname} to {$profile->nickname} - " . $e->getMessage());
}
}
return true;
}