本文整理匯總了PHP中Twitter::getUser方法的典型用法代碼示例。如果您正苦於以下問題:PHP Twitter::getUser方法的具體用法?PHP Twitter::getUser怎麽用?PHP Twitter::getUser使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Twitter
的用法示例。
在下文中一共展示了Twitter::getUser方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: serialize
// Unable to get access token. We'll settle for a request token instead.
$request = $twitter->getRequestToken();
if ($request) {
$_SESSION['request'] = serialize($request);
// Display or redirect to user to their login URL.
echo '<a href="' . $twitter->getLoginURL() . '">' . $twitter->getLoginURL() . '</a>';
} else {
// Problems.
echo 'Unable to get request token.';
}
}
}
} else {
// The user has authorized access to the application.
// Get the current user.
$user = $twitter->getUser();
/**
* The above call is the same as doing the following:
*
* $result = $twitter->api("1.1/account/verify_credentials.json");
* if($result->statusCode() == 200)
* $user = json_decode($result->body(), true);
* else
* $user = false;
**/
if ($user) {
echo "Hello, " . $user['screen_name'] . "<br />" . "<a href=\"?reset=1\">Log out</a>";
} else {
echo "Unable to fetch the users' data.";
}
}
示例2: syncFriends
function syncFriends()
{
$mt = new microAccountsTable($this->db);
$ma = $mt->getRowObject();
// get list of friends
require_once PATH_CORE . '/utilities/twitter.php';
$tObj = new Twitter(TWITTER_USER, TWITTER_PWD, $this->db);
$friends = $tObj->getFriendIds(TWITTER_USER);
foreach ($friends as $id) {
// get info for anyone not in the table
$resp = $tObj->getUser($id);
if ($resp !== false) {
// $this->db->log($resp);
// check if they exist
$ma->sid = $resp['id'];
$ma->friendlyName = $resp['name'];
$ma->profile_image_url = $resp['profile_image_url'];
$q = $this->db->queryC("SELECT * FROM MicroAccounts WHERE sid=" . $ma->sid);
if (!$q) {
// does not exist, add them
$ma->shortName = $resp['screen_name'];
$ma->tag = 'default';
$ma->service = 'twitter';
$ma->insert();
} else {
$ma->update();
}
} else {
// $this->db->log('FALSE');
}
}
// delete anyone no longer listed - set status - friends vs. not friends
}