22 * Easiest way to use OAuth now that we have an Access Token is to use |
19 * Easiest way to use OAuth now that we have an Access Token is to use |
23 * a preconfigured instance of Zend_Http_Client which automatically |
20 * a preconfigured instance of Zend_Http_Client which automatically |
24 * signs and encodes all our requests without additional work |
21 * signs and encodes all our requests without additional work |
25 */ |
22 */ |
26 |
23 |
27 if (isset($_GET['endpoint'])) { |
24 // if (isset($_GET['endpoint'])) { |
28 $endpoint = $_GET['endpoint']; |
25 // $endpoint = $_GET['endpoint']; |
29 unset($_GET['endpoint']); |
26 // unset($_GET['endpoint']); |
30 } else { |
27 // } else { |
31 $endpoint = "search/tweets"; |
28 // $endpoint = "search/tweets"; |
32 } |
29 // } |
33 |
30 |
34 $token = unserialize($_SESSION['TWITTER_ACCESS_TOKEN']); |
31 $token = unserialize($_SESSION['TWITTER_ACCESS_TOKEN']); |
35 $client = $token->getHttpClient($configuration); |
32 $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $token['oauth_token'], $token['oauth_token_secret']); |
36 $client->setUri("https://api.twitter.com/1.1/$endpoint.json"); |
|
37 $client->setMethod(Zend_Http_Client::GET); |
|
38 $client->setParameterGet($_GET); |
|
39 $response = $client->request(); |
|
40 |
33 |
41 echo $response->getBody(); |
34 $statuses = $connection->get("search/tweets", $_GET); |
|
35 // $client = $token->getHttpClient($configuration); |
|
36 // $client->setUri("https://api.twitter.com/1.1/$endpoint.json"); |
|
37 // $client->setMethod(Zend_Http_Client::GET); |
|
38 // $client->setParameterGet($_GET); |
|
39 // $response = $client->request(); |
|
40 |
|
41 // echo $response->getBody(); |
|
42 echo json_encode($statuses); |
42 |
43 |
43 } else { |
44 } else { |
44 /** |
45 /** |
45 * Mistaken request? Some malfeasant trying something? |
46 * Mistaken request? Some malfeasant trying something? |
46 */ |
47 */ |