Created
December 5, 2013 19:28
-
-
Save xeoncross/7811710 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function getTweetslist($owner_screen_name, $slug) { | |
| $oauth_access_token = "***"; | |
| $oauth_access_token_secret = "***"; | |
| $consumer_key = "***"; | |
| $consumer_secret = "***"; | |
| // https://api.twitter.com/1.1/lists/statuses.json?slug=teams&owner_screen_name=MLS&count=1 | |
| // create request | |
| $request = array( | |
| 'slug' => $slug, | |
| 'owner_screen_name' => $owner_screen_name, | |
| 'count' => 7 | |
| ); | |
| $oauth = array( | |
| 'oauth_consumer_key' => $consumer_key, | |
| 'oauth_nonce' => time(), | |
| 'oauth_signature_method' => 'HMAC-SHA1', | |
| 'oauth_token' => $oauth_access_token, | |
| 'oauth_timestamp' => time(), | |
| 'oauth_version' => '1.0' | |
| ); | |
| // merge request and oauth to one array | |
| $oauth = array_merge($oauth, $request); | |
| $base_info = buildBaseString("https://api.twitter.com/1.1/lists/statuses.json", 'GET', $oauth); | |
| $composite_key = rawurlencode($consumer_secret) . '&' . rawurlencode($oauth_access_token_secret); | |
| $oauth_signature = base64_encode(hash_hmac('sha1', $base_info, $composite_key, true)); | |
| $oauth['oauth_signature'] = $oauth_signature; | |
| // make request | |
| $header = array(buildAuthorizationHeader($oauth), 'Expect:'); | |
| $options = array( CURLOPT_HTTPHEADER => $header, | |
| CURLOPT_HEADER => false, | |
| CURLOPT_URL => "https://api.twitter.com/1.1/lists/statuses.json?". http_build_query($request), | |
| CURLOPT_RETURNTRANSFER => true, | |
| CURLOPT_SSL_VERIFYPEER => false); | |
| $feed = curl_init(); | |
| curl_setopt_array($feed, $options); | |
| $json = curl_exec($feed); | |
| curl_close($feed); | |
| return json_decode($json, true); | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment