本文整理匯總了PHP中Twitter::request方法的典型用法代碼示例。如果您正苦於以下問題:PHP Twitter::request方法的具體用法?PHP Twitter::request怎麽用?PHP Twitter::request使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Twitter
的用法示例。
在下文中一共展示了Twitter::request方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getenv
function __construct($username = 'beirutspring')
{
// prepare the client;
$twitterClient = new \Twitter(getenv('TWITTER_CONSUMER_KEY'), getenv('TWITTER_CONSUMER_SECRET'), getenv('TWITTER_ACCESS_TOKEN'), getenv('TWITTER_ACCESS_TOKEN_SECRET'));
// populate info
try {
$this->info = $twitterClient->request('users/show', 'GET', ['screen_name' => $username]);
} catch (Exception $e) {
return "Exception: {$e}";
}
}
示例2: Twitter
$access_token = '15201275-loypZtq58TRB1qoIIu6fTw6TSEqluGZ1aMKgVJjJe';
$access_token_secret = 'haKjTuzH9N6UPhOBZDKSsu6FAZzIvLNbwGhi5wfy00Y';
$twitter = new Twitter(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET, $access_token, $access_token_secret);
try {
$results = $twitter->search('#ibm');
foreach ($results as $result) {
echo "message: ", $result->text;
echo "posted at ", $result->created_at;
echo "posted by ", $result->form_user;
}
echo "\n\n\n\n";
} catch (TwitterException $e) {
echo "Error searching Twitter: ", $e->getMessage();
}
try {
$statuses = $twitter->request('statuses/retweets_of_me', 'GET', array('count' => 20));
foreach ($statuses as $status) {
echo "message: ", $status->text;
echo "posted at ", $status->created_at;
echo "posted by ", $status->form_user;
}
echo "\n\n\n\n";
} catch (TwitterException $e) {
echo "Error getting statuses from Twitter: ", $e->getMessage();
}
try {
$results = $twitter->loadUserFollowers('matthew101HS');
foreach ($results as $result) {
echo "message: ", $result->text;
echo "posted at ", $result->created_at;
echo "posted by ", $result->form_user;
示例3: twitterAction
/** Initiate request to create a twitter request token. This can only be
* done when logged into twitter
* and also as an admin
* @access public
* @return void
*/
public function twitterAction()
{
$twitter = new Twitter();
$this->redirect($twitter->request());
}
示例4: Twitter
<?php
require '../common/globals.php';
require '../common/twitter-php-3.2/src/twitter.class.php';
// Fill in the next 2 variables.
$access_token = '15201275-loypZtq58TRB1qoIIu6fTw6TSEqluGZ1aMKgVJjJe';
$access_token_secret = 'haKjTuzH9N6UPhOBZDKSsu6FAZzIvLNbwGhi5wfy00Y';
$twitter = new Twitter(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET, $access_token, $access_token_secret);
try {
$friendshipRequests = $twitter->request('friendships/incoming', 'GET');
echo $friendshipRequests;
foreach ($friendshipRequests as $request) {
echo "message: ", $request->ids;
}
echo "\n\n\n\n";
} catch (TwitterException $e) {
echo "Error getting statuses from Twitter: ", $e->getMessage();
}
?>
示例5: twitter
public function twitter()
{
$auth_url = Twitter::request();
header('Location: ' . $auth_url);
}
示例6: Twitter
<?php
require_once '../src/twitter.class.php';
// ENTER HERE YOUR CREDENTIALS (see readme.txt)
$twitter = new Twitter($consumerKey, $consumerSecret, $accessToken, $accessTokenSecret);
// See https://dev.twitter.com/docs/api/1.1
$statuses = $twitter->request('statuses/retweets_of_me', 'GET');
?>
<!doctype html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Twitter retweets of me</title>
<ul>
<?php
foreach ($statuses as $status) {
?>
<li><a href="http://twitter.com/<?php
echo $status->user->screen_name;
?>
"><img src="<?php
echo htmlspecialchars($status->user->profile_image_url);
?>
">
<?php
echo htmlspecialchars($status->user->name);
?>
</a>:
<?php
echo Twitter::clickable($status);
?>
<small>at <?php
示例7: Twitter
<?php
require '../common/globals.php';
require '../common/twitter-php-3.2/src/twitter.class.php';
// Fill in the next 2 variables.
$access_token = '15201275-loypZtq58TRB1qoIIu6fTw6TSEqluGZ1aMKgVJjJe';
$access_token_secret = 'haKjTuzH9N6UPhOBZDKSsu6FAZzIvLNbwGhi5wfy00Y';
$twitter = new Twitter(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET, $access_token, $access_token_secret);
$message = $_GET['message'];
try {
$twitter->request('direct_messages/new', 'POST', array('screen_name' => 'matthew101', 'text' => $message));
echo "\n\n\n\n";
} catch (TwitterException $e) {
echo "Error posting DM to Twitter: ", $e->getMessage();
}
?>