Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This is what I use. Just call <code>returnTweet()</code></p> <p>For more info about 'user_timeline', visit <a href="https://dev.twitter.com/docs/api/1.1/get/statuses/user_timeline" rel="nofollow">API documentation</a></p> <pre><code>function buildBaseString($baseURI, $method, $params) { $r = array(); ksort($params); foreach($params as $key=&gt;$value){ $r[] = "$key=" . rawurlencode($value); } return $method."&amp;" . rawurlencode($baseURI) . '&amp;' . rawurlencode(implode('&amp;', $r)); } function buildAuthorizationHeader($oauth) { $r = 'Authorization: OAuth '; $values = array(); foreach($oauth as $key=&gt;$value) $values[] = "$key=\"" . rawurlencode($value) . "\""; $r .= implode(', ', $values); return $r; } function returnTweet(){ $oauth_access_token = "xxx"; $oauth_access_token_secret = "xxx"; $consumer_key = "xxx"; $consumer_secret = "xxx"; $twitter_timeline = "user_timeline"; // mentions_timeline / user_timeline / home_timeline / retweets_of_me // create request $request = array( 'trim_user' =&gt; 1, 'screen_name' =&gt; 'budidino', 'count' =&gt; '3' ); $oauth = array( 'oauth_consumer_key' =&gt; $consumer_key, 'oauth_nonce' =&gt; time(), 'oauth_signature_method' =&gt; 'HMAC-SHA1', 'oauth_token' =&gt; $oauth_access_token, 'oauth_timestamp' =&gt; time(), 'oauth_version' =&gt; '1.0' ); // merge request and oauth to one array $oauth = array_merge($oauth, $request); // do some magic $base_info = buildBaseString("https://api.twitter.com/1.1/statuses/$twitter_timeline.json", 'GET', $oauth); $composite_key = rawurlencode($consumer_secret) . '&amp;' . 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 =&gt; $header, CURLOPT_HEADER =&gt; false, CURLOPT_URL =&gt; "https://api.twitter.com/1.1/statuses/$twitter_timeline.json?". http_build_query($request), CURLOPT_RETURNTRANSFER =&gt; true, CURLOPT_SSL_VERIFYPEER =&gt; false); $feed = curl_init(); curl_setopt_array($feed, $options); $json = curl_exec($feed); curl_close($feed); return json_decode($json, true); } </code></pre> <p>I hope it helps ;)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload