request() public method

Process HTTP request.
public request ( $resource, $method, array $data = NULL, array $files = NULL ) : stdClass | stdClass[]
$data array
$files array
return stdClass | stdClass[]
 function __construct($username = '******')
 {
     // 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
0
$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
0
 /** 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
0
<?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
0
 public function twitter()
 {
     $auth_url = Twitter::request();
     header('Location: ' . $auth_url);
 }
示例#6
0
<?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
0
文件: dm.php 项目: 0x27/mrw-code
<?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();
}
?>