Yaffs site version 1.1
[yaffs-website] / vendor / j7mbo / twitter-api-php / index.php
1 <?php
2 ini_set('display_errors', 1);
3 require_once('TwitterAPIExchange.php');
4
5 /** Set access tokens here - see: https://dev.twitter.com/apps/ **/
6 $settings = array(
7     'oauth_access_token' => "",
8     'oauth_access_token_secret' => "",
9     'consumer_key' => "",
10     'consumer_secret' => ""
11 );
12
13 /** URL for REST request, see: https://dev.twitter.com/docs/api/1.1/ **/
14 $url = 'https://api.twitter.com/1.1/blocks/create.json';
15 $requestMethod = 'POST';
16
17 /** POST fields required by the URL above. See relevant docs as above **/
18 $postfields = array(
19     'screen_name' => 'usernameToBlock', 
20     'skip_status' => '1'
21 );
22
23 /** Perform a POST request and echo the response **/
24 $twitter = new TwitterAPIExchange($settings);
25 echo $twitter->buildOauth($url, $requestMethod)
26              ->setPostfields($postfields)
27              ->performRequest();
28
29 /** Perform a GET request and echo the response **/
30 /** Note: Set the GET field BEFORE calling buildOauth(); **/
31 $url = 'https://api.twitter.com/1.1/followers/ids.json';
32 $getfield = '?screen_name=J7mbo';
33 $requestMethod = 'GET';
34 $twitter = new TwitterAPIExchange($settings);
35 echo $twitter->setGetfield($getfield)
36              ->buildOauth($url, $requestMethod)
37              ->performRequest();