本文整理汇总了PHP中Foreign_link::getUser方法的典型用法代码示例。如果您正苦于以下问题:PHP Foreign_link::getUser方法的具体用法?PHP Foreign_link::getUser怎么用?PHP Foreign_link::getUser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Foreign_link
的用法示例。
在下文中一共展示了Foreign_link::getUser方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: broadcast_oauth
function broadcast_oauth($notice, Foreign_link $flink)
{
try {
$user = $flink->getUser();
} catch (ServerException $e) {
common_log(LOG_WARNING, 'Discarding broadcast_oauth for notice ' . $notice->id . ' because of exception: ' . $e->getMessage());
return true;
}
$statustxt = format_status($notice);
$params = twitter_update_params($notice);
$token = TwitterOAuthClient::unpackToken($flink->credentials);
$client = new TwitterOAuthClient($token->key, $token->secret);
$status = null;
try {
$status = $client->statusesUpdate($statustxt, $params);
if (!empty($status)) {
Notice_to_status::saveNew($notice->id, twitter_id($status));
}
} catch (OAuthClientException $e) {
return process_error($e, $flink, $notice);
}
if (empty($status)) {
// This could represent a failure posting,
// or the Twitter API might just be behaving flakey.
$errmsg = sprintf('Twitter bridge - No data returned by Twitter API when ' . 'trying to post notice %d for User %s (user id %d).', $notice->id, $user->nickname, $user->id);
common_log(LOG_WARNING, $errmsg);
return false;
}
// Notice crossed the great divide
$msg = sprintf('Twitter bridge - posted notice %d to Twitter using ' . 'OAuth for User %s (user id %d).', $notice->id, $user->nickname, $user->id);
common_log(LOG_INFO, $msg);
return true;
}