예제 #1
0
 /**
  * Get Tweets
  *
  * @since    1.0.0
  * @param    string    $twitter_account   Twitter account without trailing @ char
  */
 public function get_public_photos($twitter_account)
 {
     $twitter = new \TwitterPhp\RestApi($this->consumer_key, $this->consumer_secret, $this->access_token, $this->access_token_secret);
     /*
      * Connect as application
      * https://dev.twitter.com/docs/auth/application-only-auth
      */
     $connection = $twitter->connectAsApplication();
     /*
      * Collection of the most recent Tweets posted by the user indicated by the screen_name, without replies
      * https://dev.twitter.com/docs/api/1.1/get/statuses/user_timeline
      */
     $tweets = $connection->get('/statuses/user_timeline', array('screen_name' => $twitter_account, 'entities' => 1, 'trim_user' => 0, 'exclude_replies' => 'true'));
     //var_dump($tweets);
     return $tweets;
 }
예제 #2
0
<?php

include 'RestApi.php';
/*
 * Config
 */
$consumerKey = 'YOUR CONSUMER KEY';
$consumerSecret = 'YOUR CONSUMER SECRET';
$accessToken = 'YOUR ACCESS TOKEN';
$accessTokenSecret = 'YOUR ACCESS TOKEN SECRET';
/*
 * Create new RestApi instance
 * Consumer key and Consumer secret are required
 * Access Token and Access Token secret are required to use api as a user
 */
$twitter = new \TwitterPhp\RestApi($consumerKey, $consumerSecret, $accessToken, $accessTokenSecret);
/*
 * Connect as application
 * https://dev.twitter.com/docs/auth/application-only-auth
 */
$connection = $twitter->connectAsApplication();
/*
 * Collection of the most recent Tweets posted by the user indicated by the screen_name, without replies
 * https://dev.twitter.com/docs/api/1.1/get/statuses/user_timeline
 */
$data = $connection->get('/statuses/user_timeline', array('screen_name' => 'TechCrunch', 'exclude_replies' => 'true'));
/*
 * Connect as User
 * Access Token and Access Token Secret are required!
 * https://dev.twitter.com/docs/auth/oauth/single-user-with-examples
 */