-
-
Save planetoftheweb/5914179 to your computer and use it in GitHub Desktop.
<?php | |
require 'tmhOAuth.php'; // Get it from: https://github.com/themattharris/tmhOAuth | |
// Use the data from http://dev.twitter.com/apps to fill out this info | |
// notice the slight name difference in the last two items) | |
$connection = new tmhOAuth(array( | |
'consumer_key' => '', | |
'consumer_secret' => '', | |
'user_token' => '', //access token | |
'user_secret' => '' //access token secret | |
)); | |
// set up parameters to pass | |
$parameters = array(); | |
if ($_GET['count']) { | |
$parameters['count'] = strip_tags($_GET['count']); | |
} | |
if ($_GET['screen_name']) { | |
$parameters['screen_name'] = strip_tags($_GET['screen_name']); | |
} | |
if ($_GET['twitter_path']) { $twitter_path = $_GET['twitter_path']; } else { | |
$twitter_path = '1.1/statuses/user_timeline.json'; | |
} | |
$http_code = $connection->request('GET', $connection->url($twitter_path), $parameters ); | |
if ($http_code === 200) { // if everything's good | |
$response = strip_tags($connection->response['response']); | |
if ($_GET['callback']) { // if we ask for a jsonp callback function | |
echo $_GET['callback'],'(', $response,');'; | |
} else { | |
echo $response; | |
} | |
} else { | |
echo "Error ID: ",$http_code, "<br>\n"; | |
echo "Error: ",$connection->response['error'], "<br>\n"; | |
} | |
// You may have to download and copy http://curl.haxx.se/ca/cacert.pem |
Great tutorial! I almost have it working. The only thing I think I am missing is the definition of the "callback=listTweets". Can anyone provide the code for "listTweets"? In the youtube video, (https://www.youtube.com/watch?v=GQaPt-gQVRI), around 6:25, the author mentions he programmed listTweets in his "php document". I assume he is referring to the "tweets_json.php" but I'm not sure. BTW I am new to the API functionality.
I am viewing the video in youtube you have made, and I followed all your instruction but I had encountered these problem:
Notice: Undefined index: count in C:\xampp\htdocs\Maps\tweets_json.php on line 17
Notice: Undefined index: screen_name in C:\xampp\htdocs\Maps\tweets_json.php on line 21
Notice: Undefined index: twitter_path in C:\xampp\htdocs\Maps\tweets_json.php on line 25
Notice: Undefined index: callback in C:\xampp\htdocs\Maps\tweets_json.php on line 34
[]
How to solve this?
Any one help i got this error in browser
Notice: Undefined index: count in C:\xampp\htdocs\twitter\tweets_json.php on line 17
Notice: Undefined index: screen_name in C:\xampp\htdocs\twitter\tweets_json.php on line 21
Notice: Undefined index: twitter_path in C:\xampp\htdocs\twitter\tweets_json.php on line 25
Error ID: 0
Error: error setting certificate verify locations: CAfile: C:\xampp\htdocs\twitter\cacert.pem CApath: C:\xampp\htdocs\twitter
Is it possible to get tweet fav(likes) and retweets count.
Thanks for you