Creating a Simple Twitter App using oAuth and PHP

Posted in Tutorials4 years ago • Written by 148 Comments

Everyone on the web is updating to the latest & the most secure technologies with Twitter being the most hyped one as it upgraded from basic Authentication to the more secure oAuth. Earlier people had to risk their Twitter login credentials if they wanted to use some external Apps that gave them more control over their Twitter profile. Twitter would now be removing the basic Auth to fully support oAuth. As Twitter describes oAuth is:

OAuth is an authentication protocol that allows users to approve application to act on their behalf without sharing their password. More information can be found at oauth.net or in the excellent Beginner’s Guide to OAuth from Hueniverse.

As the title suggests, today we’ll be making a basic application which updates your Twitter status using oAuth and PHP. So let’s get started without wasting anymore time!

DOWNLOAD THE LIBRARY HERE!

NOTE: I strongly suggest that you should click on each of the screen-shots below, so that you can clearly understand what’s going on!

Before starting up, I also suggest you to read the other article on Updating Twitter using PHP as it has some background information about this article. Read it here!

SETTING IT UP

To get started open up notepad or any other code editor and make three files “index.php, style.css & update.php“. Now download the “download this Twitter oAuth library” made by Jaisen Mathaihere“. It is a ready-made library “stamped” by Twitter’s API (itself) which helps you to connect to Twitter using oAuth. Now place all these files in a folder and they should look something like this:

REGISTERING YOUR APPLICATION ON TWITTER

First of all we’ll need to register an app for you on Twitter so that you get your API keys you’ll use.

After reading that previous statement a question might have taken birth in  your mind, What’s the purpose of  getting these API Keys from Twitter?

We need the API Keys for getting our Application (app) registered on Twitter so that Twitter gives us the right to get the users/visitors authenticated and get their credentials/profile info from Twitter. With the increasing number of Twitter account frauds these days, I think that oAuth is the best step taken by Twitter towards user security. Also, the API keys let Twitter know of the URL where the user will be redirected to after successful authentication/login.

So for that (getting our app registered on Twitter) click here or go to http://twitter.com/apps. Note that you’ll need to login with your Twitter account to register an APP. The registration page that twitter provides is like the one below. I’ll describe everything as we go on!

I have explained the form on the screenshot above so I strongly advise you to have a close look to the form and see what to fill. Below, I have explained all the elements of the file;

  • Application Icon: If you want to give a pictorial representation to your app then this is the way!
  • Application Name: Your application’s name. Be ultra-sure to make it catchy!
  • Description: A small description for your application.
  • Application Website: A direct link to your application’s website. (For reference)
  • Organisation: Your organisation {Your may name your website here}, although not needed.
  • Website: Your Organisation’s website {Your main homepage}, not needed {just for reference}
  • Application Type: This will probably be Browser unless you use Twitter oAuth in a software.
  • Callback URL: The URL where Twitter should redirect a user after successful authentication! {See the screenshot for more}
  • Default Access Type: It should be Read & Write unless you just need to use the profile information of a user.
  • Use Twitter for login: If you are using Twitter as a Login to your website/application then check this otherwise no need!
  • Captcha: That’s the most difficult part! ;) haha..Just a captcha and is required!

After that just click on Save and you’ll be redirected to a page where Twitter will give you your API info. in the form of a Consumer Key & the Consumer Secret Key. The page will look something like the one below:

PREPARING TO MAKE THE APPLICATION

To get started, we’ll first need to fill the API keys, we got from Twitter in our Application’s library so that we don’t get confused later on! To do so open the secret.php file in the lib folder and you’ll see something like below:


<?php
$consumer_key = '<PLACE YOUR CONSUMER KEY HERE>';
$consumer_secret = '<PLACE YOUR CONSUMER SECRET KEY HERE>';
?>

Now just add the Consumer Key & the Consumer Secret you got from Twitter in between the quotes. Below is the copy of the secret.php file that 1stwebdesigner’s Twitter oAuth application is using:


<?php
$consumer_key = 'vUztW1221HktEoi1MD3hxg';
$consumer_secret = '8R7gXaKaGfHHjtMxj6ennJMd0c8esDP4nCsKjiJAk';
?>

These API keys {consumer key, consumer secret} enable Twitter to redirect and process your oAuth request to Twitter for login.

OUR APPLICATION FILES

Index.php: Basically this file will do all our work as it shows the “Sign In Through Twitter” button and then processes all our oAuth request using the oAuth library we are using. Co-incidentally, Twitter also redirects the user to this file after successfull authentication {Remember the screenshot above ?}

Update.php: You’ll update your Twitter status using this file. Uses index.php file for form processing. (Explained below!)

Style.css: Contains all the styles that we’ll use for our application.

WRITING THE APPLICATION

Open the Index.php file you made and add the following code to it:


<?php

session_start();

include 'lib/EpiCurl.php';
include 'lib/EpiOAuth.php';
include 'lib/EpiTwitter.php';
include 'lib/secret.php';

$twitterObj = new EpiTwitter($consumer_key, $consumer_secret);
$oauth_token = $_GET['oauth_token'];
 if($oauth_token == '')
 {
 $url = $twitterObj->getAuthorizationUrl();
 echo "<div style='width:200px;margin-top:200px;margin-left:auto;margin-right:auto'>";
 echo "<a href='$url'>Sign In with Twitter</a>";
 echo "</div>";
 }
 else
 {
 $twitterObj->setToken($_GET['oauth_token']);
 $token = $twitterObj->getAccessToken();
 $twitterObj->setToken($token->oauth_token, $token->oauth_token_secret);
 $_SESSION['ot'] = $token->oauth_token;
 $_SESSION['ots'] = $token->oauth_token_secret;
 $twitterInfo= $twitterObj->get_accountVerify_credentials();
 $twitterInfo->response;

 $username = $twitterInfo->screen_name;
 $profilepic = $twitterInfo->profile_image_url;

 include 'update.php';

 }

if(isset($_POST['submit']))
 {
 $msg = $_REQUEST['tweet'];

 $twitterObj->setToken($_SESSION['ot'], $_SESSION['ots']);
 $update_status = $twitterObj->post_statusesUpdate(array('status' => $msg));
 $temp = $update_status->response;

 echo "<div align='center'>Updated your Timeline Successfully .</div>";

 }

?>

Now I’ll be explaining the whole code used above below (in point form):

  • We start off by firing our session using:

session_start();

 

The pre-built PHP function that we are usign above just creates a session or resumes the current one.

  • To keep the application as simple as we can we include all the files from the library including the secret.php file:

include 'lib/EpiCurl.php';
 include 'lib/EpiOAuth.php';
 include 'lib/EpiTwitter.php';
 include 'lib/secret.php';

We do so as we’ll be interpreting everything in our index.php file.

  • The rest of the code just helps in getting the user logged in to Twitter using the access tokens.

$twitterObj = new EpiTwitter($consumer_key, $consumer_secret);
 $oauth_token = $_GET['oauth_token'];
 if($oauth_token == '')
 {
 $url = $twitterObj->getAuthorizationUrl();
 echo "<div  style='width:200px;margin-top:200px;margin-left:auto;margin-right:auto'>";
 echo "<a href='$url'>Sign In with Twitter</a>";
 echo "</div>";
 }
 else
 {
 $twitterObj->setToken($_GET['oauth_token']);
 $token = $twitterObj->getAccessToken();
 $twitterObj->setToken($token->oauth_token,  $token->oauth_token_secret);
 $_SESSION['ot'] = $token->oauth_token;
 $_SESSION['ots'] = $token->oauth_token_secret;
 $twitterInfo= $twitterObj->get_accountVerify_credentials();
 $twitterInfo->response;

 $username = $twitterInfo->screen_name;
 $profilepic = $twitterInfo->profile_image_url;

 include 'update.php';

 }

After that we define the variables twitterObj & oauth_token to make it easier for us to connect and authenticate with Twitter. Then we open our if statement and check the oauth_token which is our access tokes for the account that will be authenticated with Twitter. We then redirect the user to Twitter’s authentication page using the $url which is defined in one the library files. The $url is made using the access token and the Twitter oAuth login link. One of the sample $url is:

http://twitter.com/oauth/authorize?oauth_token=c1iKl42xnvOA76jIqzV4zXRVqFZcYJlYBQsXJC4Hbhw

You can clearly see how Twitter well Twitter uses the oauth_tokens. After that we just open our session with Twitter and then get the profile information of the user from Twitter:


$twitterInfo= $twitterObj->get_accountVerify_credentials();
 $twitterInfo->response;

 $username = $twitterInfo->screen_name;
 $profilepic = $twitterInfo->profile_image_url;

Here we defined the twitterInfo variable which is in short getting a user’s profile credentials from the $twitterObj data and then we use the screen_name & profile_image_url functions to get the profile name and profile image of the logged in user. At the same time we are assigning variables to the profile name and profile and profile image which we will use in the update.php file.

After that we are also including the update.php file using the snippet below:

 include 'update.php';

Now copy the code below to your update.php file:


<html>
<head>
<title>Twitter oAuth Application by 1stwebdesigner | Update your status</title>
<link rel="stylesheet" href="style.css" type="text/css" media="screen, projection" />

</head>
<body>
<h1>Hello and Welcome to the oAuth Tutorial</h1>
<?php $_SESSION['twitter_profile']; ?>
<div id="form"><!--Start form-->
<p>Twitter Handle: <?php echo $username ?></p>
<p>Profile Picture: <br /><?php echo "<img src='$profilepic' />" ?><br /></p>
<label>Update Twitter Timeline</label><br />
<form method='post' action='index.php'>

<br />
<textarea  name="tweet" cols="50" rows="5" id="tweet" ></textarea>
<br />
<input type='submit' value='Tweet' name='submit' id='submit' />
</form>
</div><!--End Form-->
</body>
</html>

This is just a simple HTML page consisting of small chunks of PHP code for showing the user’s username, profile picture of the user as uploaded on Twitter. The page also consists of a text box which the user can use to update his/her status timeline on Twitter. You might have noticed by now that I am using the index.php file for form processing. The code that processes this form and posts to twitter is the one below (already in our index.php file):


if(isset($_POST['submit']))
 {
 $msg = $_REQUEST['tweet'];

 $twitterObj->setToken($_SESSION['ot'], $_SESSION['ots']);
 $update_status = $twitterObj->post_statusesUpdate(array('status'  => $msg));
 $temp = $update_status->response;

 echo "<div align='center'>Updated your Timeline Successfully  .</div>";

 }

Here we are taking the data from the textbox named tweet and then posting it to twitter and then notifying the user that his/her message was successfully and his/her timeline was updated.

Our style.css file doesn’t have any special styles that we need to discuss here. They were just used to style the update form.

NOTE: You may want to add the character count and limit as Twitter doesn’t accept any Tweets which consists of more than 140 characters {Even from the API}. I have explained it in my previous tutorial on 1stwebdesigner about Updating Twitter using Twitter API and PHP.

You may now download the completed application files here but don’t forget to edit the secret.php file with your API keys as it won’t work without it. Feel free to build on the application we made today!

TWITTER APPLICATIONS YOU USE USING oAUTH

We all know that Twitter provides an easy-to-use interface for its users. The main advantage of using oAuth is that users can see what applications have access to their profiles. If you want to check that then you can do so by:

  • Login through Twitter (web-service).
  • Go to Settings after successful login.
  • Then click on the Connections tab.
  • On that page, Twitter gives a list of all the apps that have access to your profile.

You can check that easily by following the screenshot below:

This is a screen-shot of my Connections page which is showing me all the Twitter websites/applications I have given access to!

FURTHER READING

There’s another great Twitter oAuth library made by @abraham which can be seen in action here and it can be downloaded here. Tutorials regarding that library are available here!

That’s it! If you have anything to add or have a query then feel free to comment on this post. Thanks ;)

If you enjoyed this article, get email updates (it's free).

Join over 77,235 Subscribers Today.

4 Written ArticlesWebsiteGoogle+

Blog: TutorialsWalk Twitter: @abhishekwebin

148 Comments Best Comments First
  • Jeff

    Tuesday, September 28th, 2010 11:33

    46

    Hi Abhishek,

    I have used your module for one of my site and it works great on my local pc which has PHP 5.2.9, however, when I use in live server having PHP 5.1.6, the thing is not working.

    I have updated the secret.php for live site as it required, however, in step 1 it self, it does give me like http://twitter.com/oauth/authorize?oauth_token=

    means something is going wrong. Can you please help for this since i am trying it from last 2 days.

    Jeff

    +2
  • Kelvin Chan

    Tuesday, October 18th, 2011 20:36

    119

    great tutorial, but I can’t seem to get the oauth_token.. :(

    +1
  • robbie

    Tuesday, September 7th, 2010 02:01

    35

    Hello … just to give my gratitude at first when i saw this tutorial … i passed it up because it looked very technical …but as the hours passed and the frustration kicked in i came back across … and its brillant exactly what i have been looking for….. BUT of course always a but…. when i follow all the instructions and upload the files i get this parse error ….

    Parse error: syntax error, unexpected T_CONST, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or ‘}’

    … on line 4 of the EpiCurl.php file ….HELP i checked the Phpinfo of my site i have curl enabled and it is quite a late version . Any help would be super appreciated

    +1
    • Abhishek Bhardwaj

      Sunday, September 12th, 2010 07:56

      43

      That means that your server has PHP4. This application just works in PHP5!
      But if you have PHP5 then either the cURL extension on that isn’t installed or it isn’t configured properly.

      -1
  • Peter

    Friday, October 15th, 2010 15:36

    51

    Many thanks for the tutorial. It works!

    0
  • phillNub

    Friday, October 8th, 2010 22:06

    50

    hi, I am having trouble setting this up for my website, basically what I need to do is send a tweet when there has been new values added to a mysql database.

    there does not seem to be anything on the web that tells me that?

    please help!

    0
    • Balaji

      Sunday, February 27th, 2011 20:42

      72

      me too have the same problem :(

      0
  • Kevincornett

    Saturday, October 23rd, 2010 05:05

    55

    Perhaps I’m doing this wrong. When I click the log in with twitter link, I get an HTTP500 error page. I thought I had followed the directions to the letter. Any ideas?

    0
  • Ross

    Friday, October 22nd, 2010 22:42

    54

    This is a brilliant script and I have it all working and running periodic updates from my database :)

    I have a problem though! Whenever I include the pound symbol (£), it fails! The response I get is “Invalid signature” which doesn’t make sense as it works fine any other time. I’ve tried the different codes for the symbol and putting it through various string converters but no luck.

    Any ideas?

    0
  • Terri Ann

    Friday, October 22nd, 2010 05:30

    52

    Fantastic tutorial – I really appreciate your posting the example. I’ve been having a heck-of-a-time with oAuth but that download made a new project move so much faster! Too bad you didn’t include passing the callback URI in the demo. I’ll have to go and add that in. I hate relying on the value I set in the application setup – a bad practice IMHO.

    Thanks again!

    0
  • Gerri

    Sunday, October 3rd, 2010 21:53

    49

    The questions I have is, how do I set up something so that readers on one of my sites can auto install twitter backgrounds using oAuth. If it is easier for you, you can just send me an email. Your help would be much appreciated.

    0
  • Mike the Pike

    Wednesday, September 22nd, 2010 20:41

    45

    Hi just wondering if you have ever pulled posts out fo twitter for website consumption with this. I got this working no problem but really what I want to do it more a twitter2html thing although it uses basic authentication.

    0
  • Alexwhin

    Saturday, October 23rd, 2010 21:11

    56

    I’m having the same issue :/

    0
  • Jeffrey Bennett

    Wednesday, September 29th, 2010 02:00

    47

    Hi there! Your demo URL sends me to a page that says “This Account Has Been Suspended”. I would love to see it up and running! Thanks! :)

    0
    • Abhishek

      Friday, October 1st, 2010 07:37

      48

      Hey, Sorry for the downtime! It was due to a stupid error made by my hosting provider. The tutorial demo is now back up and you can see it running. Sorry once again for the inconvinience!

      0
  • Rob

    Tuesday, November 2nd, 2010 23:17

    57

    Great tutorial!

    Hey Ross, how did you integrate this code to read value from your database and submit to twitter? I tried, but it seems to just fizzle.

    0
  • Joan Izquierdo

    Friday, February 11th, 2011 11:29

    70

    Thanks for this guide! It’s great! and now I have a problem …

    The first time it works correctly, but after the user must “Sign In with Twitter” every time :-(

    Are there solution for this problem? Thanks

    0
    • Abhishek

      Tuesday, March 1st, 2011 02:14

      73

      Yeah! use a database to store the Token information.

      0
  • Alesha

    Wednesday, February 23rd, 2011 16:25

    71

    I have a problem with the oauth token,
    When I try to sign in to authenticate, it does not generate an oauth token. When I hover over ‘Sign In’ this is the link:
    http://twitter.com/oauth/authorize?oauth_token=

    then I get an error from twitter, because there is no token

    can anybody help?

    0
    • Abhishek

      Tuesday, March 1st, 2011 02:14

      74

      Add your API keys to secret.php file!

      0
  • Irina

    Monday, July 12th, 2010 12:35

    1

    Great tutorial! Thanks. I just wanted to make a similar app :)

    0
    • Abhishek

      Tuesday, July 13th, 2010 00:03

      6

      Glad you liked it :)

      0
  • Yankymetro

    Wednesday, January 26th, 2011 23:21

    67

    When I open the library file, there’s no file called index.php… Do I create it?

    0
  • Maarten Keyman

    Monday, January 17th, 2011 20:45

    66

    How to integrate the CSS from your previous tutorial with this one? Please help me!

    0
    • Abhishek

      Wednesday, February 9th, 2011 01:35

      69

      Its already integrated?

      0
  • Dave Lu

    Saturday, December 4th, 2010 04:39

    60

    dude… just store it in the DB.. someone mentioned it above as well, and they got it working.

    great tutorial by the way Abhishek!

    0
  • jm

    Friday, December 3rd, 2010 13:08

    59

    I’m in the same boat. Everything is working minus actually updating

    0
  • Scott

    Monday, November 29th, 2010 15:31

    58

    I have followed this tutorial and everything seems to work apart from the actual Twitter timeline being updated. The scripts all run error free and I see the message telling me the timeline has been updated but the actual Tweet doesn’t appear in my timeline. Anyone got any ideas?

    0
  • Zoyx

    Friday, December 10th, 2010 04:55

    61

    Same exact thing for me. Everything seems to work, but no update showing up on Twitter. Did something at Twitter get changed recently?

    0
  • Abhishek Bhardwaj

    Thursday, December 16th, 2010 08:00

    62

    Hello folks,
    The demo is working fine for me @ http://tutorialswalk.info/demo/twitter-update-php-oauth/ I just tweeted this using that demo: http://twitter.com/#!/Abhishekwebin/status/15314744860741632
    Feel free to email me @ ‘abhishek66ster[at]gmail.com’ and I’ll walk you through the error!
    Thanks :)
    Abhishek Bhardwaj

    0
  • Anonymous

    Wednesday, January 5th, 2011 23:46

    65

    Great tutorial. I can’t wait to dive into this later this evening! It will make developing my Twitter app a cinch!

    0
  • Anonymous

    Wednesday, January 5th, 2011 23:44

    64

    You’re going to have to put an authenticate link in your backend and save the oauth tokens that twitter passes back to your MySQL database. Then you can just do exactly this but get the oauth tokens from you DB instead.

    0
  • Vladimír Skoupil

    Wednesday, December 22nd, 2010 22:21

    63

    Also thanks for great tutorial.
    I’d like to ask you, if is it possible to go straight to form and directly type the tweet without prompting me to click Allow button on twitter.com…

    0
    • Abhishek

      Wednesday, February 9th, 2011 01:35

      68

      It was possible until a few days ago but they closed that method now!

      0
  • Jordan Walker

    Wednesday, July 14th, 2010 14:52

    14

    Wow, excellent tutorial with very detailed instruction.

    0
  • SG

    Wednesday, July 14th, 2010 20:22

    15

    Great post!

    Can you also tell us how to test it locally? I want to develop and test an app locally before uploading it. What should be the web / callback URL for this and how should localhost / server handle it?

    Thanks a lot.

    0
  • drooh

    Wednesday, July 21st, 2010 00:32

    19

    I dont understand, everytime I have to click to sign in authenticate with twitter? It would be nice to just do that once and not have to do it every time you wanted to post to twitter.

    0
    • Francesco

      Thursday, September 2nd, 2010 19:27

      32

      Hi drooh,
      I have your same problem.
      have you solved?

      tnx

      0
    • Abhishek Bhardwaj

      Saturday, July 24th, 2010 22:30

      21

      That’s because I am not storing the token keys anywhere. This is just a simple app! Maybe in the future, I’ll have another tutorial on 1WD that connects to a database and stores the authentication keys so that the user doesn’t have to login again and again!!

      0
      • Jim

        Thursday, August 12th, 2010 12:53

        29

        It would be awesome if you could add it to this tutorial any time soon.
        Thank you very much

        0
  • yankymetro

    Saturday, July 17th, 2010 03:27

    17

    I don’t know what’s the callback URL. It’s hard. Explain it to me better. Thanks.

    0
    • Abhishek

      Saturday, July 17th, 2010 21:50

      18

      Do you really think its hard? Check the first screenshot and that’s your answer otherwise the callback URL is: http://your-website.com/“”index.php”" ……..

      0
  • Zachary Collins

    Wednesday, July 14th, 2010 04:42

    12

    Hey there,
    Great tutorial! Only problem I am having is when I connect my account and it brings me back to the index.php page, I refresh, and it doesnt load the user.

    Thanks,
    Zachary Collins

    0
    • Abhishek

      Wednesday, July 14th, 2010 10:55

      13

      Check your callback URL on Twitter, and did you change the API Keys in secret.php file?

      0
      • Carter Thayer

        Tuesday, September 7th, 2010 02:15

        34

        I checked both, the refresh problem is still happening. Let me know if you find a solution. Also, same thing is happening on your demo page.

        0
  • Jaisen Mathai

    Monday, July 12th, 2010 23:46

    3

    I added this article to the readme of the Twitter-Async library on Github.

    http://github.com/jmathai/twitter-async

    Thanks for the write up.

    0
    • Abhishek

      Tuesday, July 13th, 2010 04:23

      8

      Thanks for adding it :)

      0
  • Rvarm1

    Tuesday, July 13th, 2010 06:51

    10

    Hi! I was making a similiar application, but whenever I clicked sign in with twitter, it gave me this error:
    “Woah there!
    This page is no longer valid. It looks like someone already used the token information you provided. Please return to the site that sent you to this page and try again … it was probably an honest mistake.”

    Can you please help me? I already tried resetting the keys, but it didnt work.

    Thanks for your help!

    0
    • Abhishek

      Tuesday, July 13th, 2010 08:29

      11

      I think the tokens are valid for only 2 minutes. Everytime you open your oAuth app, the application connects to the API and gets your token automatically..try refreshing the page and clearing your cache + cookies, it should work..

      The error you are talking about ignites when your token has expired..and most times its due to the fact that someone else used that..after all there are 1000s of Twitter oAuth apps running on the web and these tokens are distributed among everyone! :D

      0
  • Siddharth

    Monday, July 12th, 2010 21:10

    7

    hey thats wonder tutorial..
    am actually using these.. and could u say..
    in case i we want to use these if the user s not online.. but registered..
    how to get and store the oauth token and secrets ?
    and how to ue them again to update the satus ?/
    can u help me out ?

    0
    • Abhishek

      Monday, July 12th, 2010 23:56

      4

      That can be done using a database which stores all tokens! I also emailed you from your website so I guess we should continue our conversation there :D

      0
  • seddik

    Friday, July 23rd, 2010 16:44

    20

    this tutorial helped me really much but just one thing i didn’t understand, for the callback url, I tried http://localhost/twitter/index.php but at twitter application settings it doesn’t accept this url ?

    0
    • Abhishek Bhardwaj

      Saturday, July 24th, 2010 22:32

      22

      lol Sorry, I think Twitter doesn’t accept any URL which doesn’t have a .com or .net or all those other domain suffixes.

      0
  • Mark

    Sunday, August 22nd, 2010 10:28

    31

    Thanks to you and Jaisan for all the great articles on the Twitter API…
    I seem to missing something, it seems that I can only access twitter by starting from scratch and fails the tokens on repeated access, part of which you may have touched on above about token lives. My question would be is it possible to create an application that can be called as a stand-alone and update my Twitter account without repeating the Twitter authorization each time? (Application would create the new tweets). Would the application have to use basic (curl) login to Twitter prior to creating the access tokens?

    0
  • Marcus

    Friday, September 3rd, 2010 17:55

    33

    Thanx for this great tutorial!!!
    I´ve been looking for a long time for a code like this!

    0
  • Josh

    Thursday, March 3rd, 2011 18:23

    75

    I am getting an error when trying to run the index.php in browser:

    “Fatal error: Call to undefined function curl_multi_init() in E:\WEB FOLDERS\lib\EpiCurl.php on line 21″

    Help?

    0
    • Abhishek

      Wednesday, April 13th, 2011 03:52

      82

      It’s indeed a problem with cURL! Also use “http://127.0.0.1″ as your callback URL when testing Twitter oAuth on localhost!

      0
    • Robin

      Wednesday, March 16th, 2011 15:41

      76

      It might be problem with cURL. Try this http://www.robinthomas.in/php/enable-curl-in-wamp/

      0
  • Sebastien

    Thursday, September 9th, 2010 22:10

    37

    Hey,

    Thanks a lot of this write up. I don’t know why but for some reason oAuth just confuses the heck out of me and this helped quite a bit.

    I do have a question though :) I need each call to have a custom callback page to identify our clients. I know this is possible because near the callback input on the twitter application settings page it explains that I can do so by including a oauth_callback. I tried poking around in your code to see if this was supported somehow but I can’t seem to find it. I have my fingers crossed that you’ll tell me I just need to include it in some sort of parameters array so one of the constructors :)

    Any help would be appreciated and thanks again :)

    0
    • Sebastien

      Friday, September 10th, 2010 17:20

      38

      For anyone that might have the same problem as me, I solved it by using the code found here: https://docs.google.com/View?docID=dcf2dzzs_2339fzbfsf4

      It’s very similar to the tutorial here (though not explained as well, you might have to dig a little in the code and read his documentation file) but it clearly shows how to define your callback when you request a token. This would allow you to pass along GET variables or go to different domains (which is how I identify clients)

      HTH!

      0
      • Abhishek Bhardwaj

        Sunday, September 12th, 2010 08:08

        42

        Ya, Abraham’s Twitter oAuth library is more user and feature friendly! Jaisen’s library doesn’t supprt that well. There are some tutorials out there on Abraham’s library too which can be found here: http://wiki.github.com/abraham/twitteroauth/links

        0
  • Endolino

    Wednesday, September 8th, 2010 14:44

    36

    Hello,
    reading your tutorial will drop some errors in my mind. In my application i wanna only send messages to my twitter account avoiding endless login in with username and password.
    Where i am be able to get the secret password which i can put into the constructor as 3th and 4th argument?

    0
    • Abhishek Bhardwaj

      Sunday, September 12th, 2010 08:01

      40

      Store your tokens and other login credentials in your database!

      0
      • Cristian

        Saturday, September 18th, 2010 16:56

        44

        Please give me a real example (code please!!!) because I’m new in PHP…
        Thank you,
        Cristian

        0
  • bharath

    Sunday, August 15th, 2010 16:07

    30

    Thank You i was searching for this in many places you teached me very easily
    Thanks ………..

    0
  • Rims

    Thursday, July 29th, 2010 12:51

    23

    Hello… i have used the same code in my php project bcz i want to run it on localhost.
    I have also registered application in twitter and changed the secret.php file. but then also i m getting error….
    Call to undefined function curl_multi_init() in C:\Program Files\xampp\htdocs\twitter\lib\EpiCurl.php on line 21.

    Plz tell me how to resolve this error.
    I have searched about it there is no prob with PHP installed bcz it is giving information when i call function phpinfo();.

    0
    • Abhishek

      Friday, July 30th, 2010 19:48

      24

      The problem is that you do not have cURL extension installed (or it is disabled).
      Reconfigure it and it should work!

      0
  • neko

    Sunday, August 1st, 2010 03:01

    25

    hello.
    your tutorial so easily to understand!
    thank you so mach.

    but i have a problem.
    i try to tweet in japanese,status is incorrect.
    In english , status is OK.

    i think encode problem.
    how can i solve ?
    please help me.

    0
    • Neko

      Thursday, August 5th, 2010 12:12

      26

      I solve that.
      I try to make original script,so I can tweet in multibyte(japanese).
      thank you!

      0
      • Abhishek Bhardwaj

        Sunday, September 12th, 2010 08:05

        41

        Glad that you could find the solution yourself!

        0
        • Petra

          Sunday, February 19th, 2012 17:21

          138

          Hi, I’m having the same problem here, I’ve been told that some of my followers can’t read the tweets in multibyte letters. If either of you can help me in any way, I would be grateful. Thnx :D

          0
  • cheza

    Tuesday, August 10th, 2010 09:19

    28

    Hi,

    just out of curiosity. How do you verify a user, once you have all the needed tokens, if he revisits your page. Clearly you’d have to – somehow – identify that visitor als the one specific user.

    Actually, in my opinion, at that point you won’t get around asking for twitter screen name and password, which you will have to compare to other screen names and pws which will have to be stored in your DB. => All bonuses of oauth are gone by then… I am currently stuck at that point in developing a twitter app.

    It would be nice if you could point me in the right direction! (even though I am developing with RoR instead of PHP :)!)

    thanks cheza

    0
    • Abhishek Bhardwaj

      Sunday, September 12th, 2010 07:59

      39

      That can be done using a database.
      You’ll have to store the login credentials & tokens in your database. Then if a user revisits the page, you can identify him using the tokens & credentials.

      0
    • Terri Ann

      Friday, October 22nd, 2010 05:34

      53

      After the user verifies with Twitter and the token is passed back the these two lines hold the key to what you need to store in the database:

      $_SESSION['ot'] = $token->oauth_token;
      $_SESSION['ots'] = $token->oauth_token_secret;

      Those two values are used again here:

      $twitterObj->setToken($_SESSION['ot'], $_SESSION['ots']);

      Before posting the status update. Replace the setting of the session super global with any kind-of database set and get functionality and you will be on your way. Everything you need is in that index.php file!

      0
  • freak

    Sunday, August 8th, 2010 23:32

    27

    It doesn’t generate a oauth_token for me, I have edited the secret.php but it doesn’t work. I’m using a .in domain from securesignup.net, site is hosted on 0fees.net.

    0
  • priya

    Saturday, November 5th, 2011 09:51

    123

    Hi
    we get user name of the person through this code
    $username = $twitterInfo->screen_name;

    but i dont know how to get email id of him

    will please answer?

    0
    • Alex

      Tuesday, April 10th, 2012 08:08

      147

      print the whole array as take what you required.
      i.e
      print_r($twitterInfo);

      0
  • sonu

    Wednesday, November 16th, 2011 12:23

    125

    I want to upload image on twitter account with php code can anyone help me regarding this.

    Thanks for this

    0
  • Francis

    Wednesday, November 30th, 2011 05:27

    126

    Great tutorial, I’m planning to develop my own twitter API and this one is a good example to start for. Thanks for sharing.

    0
  • tonny

    Friday, December 9th, 2011 18:20

    129

    How can i decode twitterInfo object?

    0
  • Pur

    Sunday, December 4th, 2011 22:57

    127

    Hi Bhardwaj,

    I’ve tried this script on my website for member area (where the session_start() is always there). Getting $username and $profilepic when visitor redirected to callback URL is work nicely. It means that writing $_SESSION['ot'] and $_SESSION['ots'] also good. But i always fail sending post to twitter. I tried to display error by adding print_r($temp) and I found error like “Invalid/Token Expired”. So that after doing POST Request there are missing value of $_SESSION['ot'] and $_SESSION['ots'] even if I add or remove session_start() on the top of page.

    I’ve also tried other different tutorials and simply not working when sending tweet. I put customer_key and customer secret correctly, and set my application permission to read and write, give correct callback URL, domain and web address. Still not working.

    Because there are missing $_SESSION['ot'] and $_SESSION['ots'] value when sending Post Request, I tried to record those string to my myql table when getting back to Callback URL (where $_SESSION['ot'] and $_SESSION['ots'] got their values correctly), and then call them when posting tweet. And still not working.

    Can you tell me why I loss $_SESSION['ot'] value when sending POST Request even if i send it to different file , and why I got error: Invalid/token expired even i use toke key from mysql record.

    It seems something causes that errors on my server but I don’t know what is it because the script doesn’t return any error until I put this print_r($temp).

    Can you help me fix this problem please!

    Thanks for your great posts.

    0
    • Pur

      Sunday, December 4th, 2011 23:08

      128

      Note:
      My server is also PHP CURL enabed, safe_mode=off, and works well in integrating facebook API with PHP.
      I really need this twitter API script, and your script is the only script that successfully displaying twitter user data on Callback, but fail sending post to twitter.
      Hope you help me fix this.

      0
  • Umer

    Wednesday, October 26th, 2011 13:10

    122

    Nice post but even in your demo once i refresh the page, my user info including picture goes off and it does not retain the session. Kindly comment and update your code to make it complete teaching beginners to retain user info as well.

    0
    • Abhishek Bhardwaj

      Friday, November 11th, 2011 23:18

      124

      This was a basic tutorial without any databases involved (Yes, you’ll need a database to retain sessions).

      0
  • Nilesh

    Sunday, October 23rd, 2011 23:38

    121

    Really good documentation specially for beginners.

    0
  • Eric Libay

    Friday, September 16th, 2011 07:35

    114

    I can’t change my “Default Access type” into “Read & Write” it always turn into Read-Only..What happen to twitter.

    0
  • ivan

    Thursday, September 22nd, 2011 20:51

    115

    I followed the instructions, step by step, but it doesn´t work fine. Twitter returns me a PIN code to put in to the app for the Authentication process ( of-band/PIN Code Authentication). This is so weird, because when I run your demo from this website, it works fine and doesn´t need the PIN code

    cheerrss!!!!!!

    0
  • motorlu panjur

    Sunday, October 2nd, 2011 23:09

    116

    is a herbal is live are you teacher systam

    0
  • Daniel

    Saturday, October 22nd, 2011 00:27

    120

    A snag which I ran into and remedied: don’t forget to enable the cURL extension in php.ini (uncomment extension=php_curl.dll). Otherwise you’ll run into ‘could not find **_curl_**() function’ errors.

    0
  • Micky

    Thursday, October 13th, 2011 03:10

    118

    Hey, get rid of the space in update.php in line 17. There are 2 spaces in that line, just delete one of them.

    0
  • evan heminger

    Tuesday, October 11th, 2011 23:20

    117

    What if I don’t have a website?

    0
  • Tonny

    Friday, December 9th, 2011 18:27

    130

    Dudz, help me how can i decode $twitterInfo->response

    0
  • Drewseph

    Tuesday, December 13th, 2011 03:06

    131

    I’m a bit confused at what I need to store in my database and where I need to call it

    I have the script working perfectly but I’d prefer to not have to authenticate every time and have to “Allow” app to post

    0
  • Andi Afriansyah

    Tuesday, March 27th, 2012 08:55

    143

    where is the url api? I have searched for the url api string in the php file. But still noting :( help me. where is update api?

    0
  • Emmanuel Chenze

    Monday, March 26th, 2012 16:00

    142

    A good tutorial. Let me try these steps and see how it works.

    0
  • saeed

    Monday, April 9th, 2012 06:36

    145

    hi guys ;
    i have question about sign in link when i want sign in to my app ,i have link url with out “oauth_token” code,
    twitter.com/oauth/authorize?oauth_token=…empty….
    what can i do ????

    0
    • Alex

      Tuesday, April 10th, 2012 08:05

      146

      your CURL is not working

      0
  • Adeel

    Tuesday, May 15th, 2012 08:48

    148

    When i log in with twitter it gets me logged in and get my details from twitter. But when i refresh page, request fails with error invalid token. Same is happening on your demo. My name and Profile picture disappears when i refresh that demo page. Kindly reply if someone understand this problem or have solution to this.

    0
  • Willz

    Friday, March 16th, 2012 14:21

    141

    Thanks for that excellent and straight forward solution!

    0
  • Mohammad Kalim

    Wednesday, March 7th, 2012 08:41

    140

    hello,

    This is awesome i really love this but i need one more thing how can i do this tweet automatically, because i want to that: I have a CMS Admin Panel of my Web-Application i want to do that when every i have enter the new product they will automatically tweet the description of the product, I just do it before entering it into the database.

    Please Guide me how to do that.

    Thanks

    0
    • saeed

      Monday, April 9th, 2012 06:32

      144

      hi guys ;
      i have question about sign in link when i want sign in to my app ,i have link url with out “oauth_token” code,
      twitter.com/oauth/authorize?oauth_token=…empty….
      what can i do ????

      0
  • Theo

    Saturday, February 4th, 2012 23:11

    134

    Hi!
    I have some ugly php error messages:
    Warning: include(lib/EpiCurl.php) [function.include]: failed to open stream: No such file or directory in /var/www/virtual/artlog.hu/htdocs/twitter/index.php on line 5

    Warning: include() [function.include]: Failed opening ‘lib/EpiCurl.php’ for inclusion (include_path=’.:/usr/share/php:/usr/share/pear’) in /var/www/virtual/artlog.hu/htdocs/twitter/index.php on line 5

    Warning: include(lib/EpiOAuth.php) [function.include]: failed to open stream: No such file or directory in /var/www/virtual/artlog.hu/htdocs/twitter/index.php on line 6

    Warning: include() [function.include]: Failed opening ‘lib/EpiOAuth.php’ for inclusion (include_path=’.:/usr/share/php:/usr/share/pear’) in /var/www/virtual/artlog.hu/htdocs/twitter/index.php on line 6

    Warning: include(lib/EpiTwitter.php) [function.include]: failed to open stream: No such file or directory in /var/www/virtual/artlog.hu/htdocs/twitter/index.php on line 7

    Warning: include() [function.include]: Failed opening ‘lib/EpiTwitter.php’ for inclusion (include_path=’.:/usr/share/php:/usr/share/pear’) in /var/www/virtual/artlog.hu/htdocs/twitter/index.php on line 7

    Fatal error: Class ‘EpiTwitter’ not found in /var/www/virtual/artlog.hu/htdocs/twitter/index.php on line 10

    Anyone?

    0
  • aaron

    Saturday, January 28th, 2012 02:06

    133

    Hi– once on my server, i tried to follow the link and sign in with twitter but i got this error:

    There is no request token for this page. That’s the special key we need from applications asking to use your Twitter account. Please go back to the site or application that sent you here and try again; it was probably just a mistake.

    the consumer secret and key were the only two devices needed, correct?

    0
    • vikash

      Tuesday, February 21st, 2012 11:30

      139

      we remove bracket” just like in screat.php error willbe remove.

      0
  • Rissa

    Saturday, January 21st, 2012 09:21

    132

    Out of ALL the tutorials I have tried out of the past week, this is the ONLY one that worked lol. Now I just have to figure out how to update the bg image instead of posting a tweet, oh geez.

    0
  • jeremy

    Thursday, February 9th, 2012 03:25

    135

    I want my script to post new blog posts, why would i have to autenticate with my browser everytime??? my script will be called by another script not by a browser, the old api was sooo much simpler. this sucks

    0
  • David Maignan

    Thursday, February 9th, 2012 19:37

    136

    Thanks for sharing. I started to experiment with it today. Nice

    0
  • Ivan

    Sunday, February 12th, 2012 11:08

    137

    Hi, I have another problem. I try with your online demo and he send my arabic chacarters BUT on my server, I can’t I get this error. Please help .
    array(2) { ["error"]=> string(34) “Could not authenticate with OAuth.” ["request"]=> string(21) “/statuses/update.json” } ( الدائري الأول ) is ( اكتب تعليقك هناfasdfasfsfsdafsdfsdfsadfdffsdafsdfdsf )
    My encoding on this message is UTF-8

    0
  • Mathias

    Monday, September 5th, 2011 17:06

    113

    Good tutorial

    Is there a way to use this API to check who unfollowed me in the last 48 house?

    0
  • Rupanjan Mukherjee

    Saturday, April 23rd, 2011 15:40

    87

    Every Thing is Understandable but my question where to put the (oauth_token ) (oauth_token_secret)
    am a newbie in this field.
    another question what will be my call back url is it http://www.xyz.com/xyz/update.php
    any body can explain?

    Thanks in advance. The topic is nice may i mistake something

    0
    • Abhishek

      Friday, May 13th, 2011 17:31

      94

      secret.php file!

      0
    • Anh

      Friday, April 29th, 2011 06:46

      88

      I’m having the same problem. I followed the tutorial exactly and I updated the secrets php script with my own keys, but it’s not “seeing” my oauth token?

      Any help would be appreciated! Thanks.

      0
  • Anh

    Friday, April 29th, 2011 08:18

    89

    Great tutorial, but there’s an error. In the “secrets.php,” the variables should be $consumerKey and $consumerSecret, not $consumer_key and $consumer_secret. You have to change this in the index.php file as well. If you don’t, the oauth token won’t register.

    0
    • Abhishek

      Friday, May 13th, 2011 17:30

      93

      No need to make such changes. Those are variable names..

      0
  • Lev

    Monday, May 9th, 2011 13:28

    92

    Don’t use the code posted here – it is OUT OF DATE (get it from the author directly at the URL provided below).

    I ran into a number of issues with the code provided here (the biggest being many status updates would outright fail because of accented characters).

    The same library (only newer code, with lots of fixes) can be found here:

    https://github.com/jmathai/twitter-async

    0
  • int

    Tuesday, May 3rd, 2011 12:14

    91

    My messages are not getting added to the time line.

    Is there something I should do to rectify it?

    0
    • Abhishek

      Friday, May 13th, 2011 17:32

      95

      Change your application’s access type to “Read/Write”.

      0
  • edwin

    Friday, April 29th, 2011 19:55

    90

    Is it possible to let the script login automatic so you can go to the page and fill in the tweet, instead of going to the page and login to twitter first.

    0
  • Zach

    Friday, April 15th, 2011 22:00

    85

    Great tutorial! Very cool potential here.

    I was struggling with a goofy error, and I just figured it out. In case anyone is in the situation where you send your tweet, the page reloads, says you successfully updated your timeline, but you DON’T see anything actually update on your feed, make sure your app is registered as Read & Write under “Default Access Type”. I had mine set to Read-only, so it wasn’t working.

    I figured it out by checking the temporary variable that gets assigned the response to the update (in index.php):

    $temp = $update_status->response;

    and found [error] => Read-only application cannot POST

    Silly error. Very simple. But fooled me nonetheless. Hopefully this post will help someone else out.
    Cheers!

    0
    • Abhishek

      Saturday, April 16th, 2011 08:58

      86

      It’ll surely help people out!

      0
  • Paul

    Thursday, April 14th, 2011 12:51

    84

    Great tutorial and have got it all working nicely. Only problem I have found is when someone tried a bit of French it didn’t get posted… Très Bien.
    Doesn’t seem to like the è!

    0
  • Rakesh

    Monday, April 11th, 2011 18:37

    78

    How can we use it to get tweek by keywords(post id ex: @cldmgc)? Atleast 10 tweeks.

    0
    • Abhishek

      Wednesday, April 13th, 2011 03:51

      81

      What do you mean by Tweaks?

      0
  • Rakesh

    Monday, April 11th, 2011 18:17

    77

    when i tried to run it it ran well but after signing in twitter took me at a page where a token was given and a message was written that “Go to and enter the following to complete the process. Can you guide me to get rid of this obstacle.

    0
    • Abhishek

      Wednesday, April 13th, 2011 03:55

      83

      Reading the tutorial properly will help you get rid of the obstacle!
      – Register your app on Twitter.
      – Enter the Key’s you get after app register in the “secret.php” file available in the enclosed source code package!

      Read the tutorial properly!

      0
  • ester

    Tuesday, April 12th, 2011 11:33

    79

    I got “….enter the following PIN to complete the process.”

    Where should I enter this PIN in order to continue with the process?
    Please, does anyone give me an answer…
    Thank you

    0
    • Abhishek

      Wednesday, April 13th, 2011 03:50

      80

      Register your application on Twitter and enter the KEY’s you get from there in the “secret.php” file!

      0
  • Dan

    Thursday, June 30th, 2011 10:38

    103

    Any idea how to use this great tool in a frame? it simply does not open the sign in link within a frame. I am aware about the policy of twitter for frames but there should be way to use it.

    What is my thinking is to open the sign in link in a new window and after authenticating, the frame should refresh itself to load required page. But I couldnt manage to do it.

    any help is welcome?

    0
    • Abhishek

      Friday, September 2nd, 2011 03:57

      111

      No need to use frames. You can instead use an AJAX-jQuery method to achieve the same!

      0
  • sai

    Tuesday, July 26th, 2011 13:33

    106

    the demo is working. but i downloaded and when i am accessing it is not working can u help me please.

    0
  • Palak

    Thursday, July 28th, 2011 13:10

    107

    Hi,

    Thanks for nice tutorial. It helps me lot. One thing I want to ask that. I want to follow the user by this api. how it can be done ? is there any particular function in twitter lib for that ? same like
    $update_status = $twitterObj->post_statusesUpdate(array(‘status’ => $msg)); as u used this for the post to twitter.
    Please tell me how can I follow the user by this api ?

    Thanks.

    0
  • bjesua

    Friday, July 29th, 2011 04:33

    108

    Hello, when i try to login i have this error on twitter

    This page is no longer valid. It looks like someone already used the token information you provided. Please return to the site that sent you to this page and try again … it was probably an honest mistake.

    Please can you help me or guide mi with this problem i had?
    i really need your answer thanks!

    0
  • Ekn

    Friday, July 22nd, 2011 14:44

    104

    I got no success in trying. The link to the DEMO is broken. Could you please, update it?

    0
    • Rean John Uehara

      Friday, July 22nd, 2011 14:59

      105

      That’s odd, the demo is working fine for me and I’ve allowed 1stwebdesigner access to my Twitter account. :|

      0
  • Rupanjan

    Tuesday, June 21st, 2011 16:50

    102

    This code is working fine than the other one
    Thanx for sharing

    Rupanjan

    0
  • jude

    Sunday, May 15th, 2011 16:38

    97

    HI ,

    Is it possible to include a username and password field so there is no request for authorization ?

    thanks in advance
    Jude Dcoutho

    0
    • Rean John Uehara

      Sunday, May 15th, 2011 17:38

      96

      Hi, as far as I am concerned the authorization is required by Twitter. But you can still go here to find out: http://dev.twitter.com/pages/oauth_faq

      0
    • Abhishek

      Friday, September 2nd, 2011 03:54

      110

      Twitter had closed that method of authentication last year itself.

      0
  • PM

    Thursday, June 2nd, 2011 23:54

    98

    Hi,

    Thanks for sharing very helpful information. Can you demonstrate how to retrieve tweets from an account?

    Thanks again,
    -PM.

    0
  • Kevin

    Sunday, June 19th, 2011 15:49

    101

    Where is the log out button so users can log out of your application AND Twitter?

    0
  • Usman

    Friday, June 17th, 2011 11:31

    99

    Hi,

    i m trying to use your code but no success for me. using same code as you have asked only changed my consumer keys. nothing less OR more. please see below URL why it is behaving like this.

    http://www.socialscratch.com/images/twitter-oauth/

    Waiting for your reply.

    0
  • ditatompel

    Monday, July 12th, 2010 12:52

    2

    Nice tutorial! Thank you for sharing! =)

    -1
    • Abhishek

      Tuesday, July 13th, 2010 00:00

      5

      Thank you!! :)

      0
  • Abhishek

    Tuesday, July 13th, 2010 00:01

    9

    Yes, It initially looks difficult but its relatively easy once you dive into the code.

    +1
  • Adeel

    Tuesday, May 15th, 2012 08:48

    148

    When i log in with twitter it gets me logged in and get my details from twitter. But when i refresh page, request fails with error invalid token. Same is happening on your demo. My name and Profile picture disappears when i refresh that demo page. Kindly reply if someone understand this problem or have solution to this.

    0
  • saeed

    Monday, April 9th, 2012 06:36

    145

    hi guys ;
    i have question about sign in link when i want sign in to my app ,i have link url with out “oauth_token” code,
    twitter.com/oauth/authorize?oauth_token=…empty….
    what can i do ????

    0
    • Alex

      Tuesday, April 10th, 2012 08:05

      146

      your CURL is not working

      0
  • Andi Afriansyah

    Tuesday, March 27th, 2012 08:55

    143

    where is the url api? I have searched for the url api string in the php file. But still noting :( help me. where is update api?

    0
  • Emmanuel Chenze

    Monday, March 26th, 2012 16:00

    142

    A good tutorial. Let me try these steps and see how it works.

    0
  • Willz

    Friday, March 16th, 2012 14:21

    141

    Thanks for that excellent and straight forward solution!

    0
  • Mohammad Kalim

    Wednesday, March 7th, 2012 08:41

    140

    hello,

    This is awesome i really love this but i need one more thing how can i do this tweet automatically, because i want to that: I have a CMS Admin Panel of my Web-Application i want to do that when every i have enter the new product they will automatically tweet the description of the product, I just do it before entering it into the database.

    Please Guide me how to do that.

    Thanks

    0
    • saeed

      Monday, April 9th, 2012 06:32

      144

      hi guys ;
      i have question about sign in link when i want sign in to my app ,i have link url with out “oauth_token” code,
      twitter.com/oauth/authorize?oauth_token=…empty….
      what can i do ????

      0
  • Ivan

    Sunday, February 12th, 2012 11:08

    137

    Hi, I have another problem. I try with your online demo and he send my arabic chacarters BUT on my server, I can’t I get this error. Please help .
    array(2) { ["error"]=> string(34) “Could not authenticate with OAuth.” ["request"]=> string(21) “/statuses/update.json” } ( الدائري الأول ) is ( اكتب تعليقك هناfasdfasfsfsdafsdfsdfsadfdffsdafsdfdsf )
    My encoding on this message is UTF-8

    0
  • David Maignan

    Thursday, February 9th, 2012 19:37

    136

    Thanks for sharing. I started to experiment with it today. Nice

    0
  • jeremy

    Thursday, February 9th, 2012 03:25

    135

    I want my script to post new blog posts, why would i have to autenticate with my browser everytime??? my script will be called by another script not by a browser, the old api was sooo much simpler. this sucks

    0
  • Theo

    Saturday, February 4th, 2012 23:11

    134

    Hi!
    I have some ugly php error messages:
    Warning: include(lib/EpiCurl.php) [function.include]: failed to open stream: No such file or directory in /var/www/virtual/artlog.hu/htdocs/twitter/index.php on line 5

    Warning: include() [function.include]: Failed opening ‘lib/EpiCurl.php’ for inclusion (include_path=’.:/usr/share/php:/usr/share/pear’) in /var/www/virtual/artlog.hu/htdocs/twitter/index.php on line 5

    Warning: include(lib/EpiOAuth.php) [function.include]: failed to open stream: No such file or directory in /var/www/virtual/artlog.hu/htdocs/twitter/index.php on line 6

    Warning: include() [function.include]: Failed opening ‘lib/EpiOAuth.php’ for inclusion (include_path=’.:/usr/share/php:/usr/share/pear’) in /var/www/virtual/artlog.hu/htdocs/twitter/index.php on line 6

    Warning: include(lib/EpiTwitter.php) [function.include]: failed to open stream: No such file or directory in /var/www/virtual/artlog.hu/htdocs/twitter/index.php on line 7

    Warning: include() [function.include]: Failed opening ‘lib/EpiTwitter.php’ for inclusion (include_path=’.:/usr/share/php:/usr/share/pear’) in /var/www/virtual/artlog.hu/htdocs/twitter/index.php on line 7

    Fatal error: Class ‘EpiTwitter’ not found in /var/www/virtual/artlog.hu/htdocs/twitter/index.php on line 10

    Anyone?

    0
  • aaron

    Saturday, January 28th, 2012 02:06

    133

    Hi– once on my server, i tried to follow the link and sign in with twitter but i got this error:

    There is no request token for this page. That’s the special key we need from applications asking to use your Twitter account. Please go back to the site or application that sent you here and try again; it was probably just a mistake.

    the consumer secret and key were the only two devices needed, correct?

    0
    • vikash

      Tuesday, February 21st, 2012 11:30

      139

      we remove bracket” just like in screat.php error willbe remove.

      0
  • Rissa

    Saturday, January 21st, 2012 09:21

    132

    Out of ALL the tutorials I have tried out of the past week, this is the ONLY one that worked lol. Now I just have to figure out how to update the bg image instead of posting a tweet, oh geez.

    0
  • Drewseph

    Tuesday, December 13th, 2011 03:06

    131

    I’m a bit confused at what I need to store in my database and where I need to call it

    I have the script working perfectly but I’d prefer to not have to authenticate every time and have to “Allow” app to post

    0
  • Tonny

    Friday, December 9th, 2011 18:27

    130

    Dudz, help me how can i decode $twitterInfo->response

    0
  • tonny

    Friday, December 9th, 2011 18:20

    129

    How can i decode twitterInfo object?

    0
  • Pur

    Sunday, December 4th, 2011 22:57

    127

    Hi Bhardwaj,

    I’ve tried this script on my website for member area (where the session_start() is always there). Getting $username and $profilepic when visitor redirected to callback URL is work nicely. It means that writing $_SESSION['ot'] and $_SESSION['ots'] also good. But i always fail sending post to twitter. I tried to display error by adding print_r($temp) and I found error like “Invalid/Token Expired”. So that after doing POST Request there are missing value of $_SESSION['ot'] and $_SESSION['ots'] even if I add or remove session_start() on the top of page.

    I’ve also tried other different tutorials and simply not working when sending tweet. I put customer_key and customer secret correctly, and set my application permission to read and write, give correct callback URL, domain and web address. Still not working.

    Because there are missing $_SESSION['ot'] and $_SESSION['ots'] value when sending Post Request, I tried to record those string to my myql table when getting back to Callback URL (where $_SESSION['ot'] and $_SESSION['ots'] got their values correctly), and then call them when posting tweet. And still not working.

    Can you tell me why I loss $_SESSION['ot'] value when sending POST Request even if i send it to different file , and why I got error: Invalid/token expired even i use toke key from mysql record.

    It seems something causes that errors on my server but I don’t know what is it because the script doesn’t return any error until I put this print_r($temp).

    Can you help me fix this problem please!

    Thanks for your great posts.

    0
    • Pur

      Sunday, December 4th, 2011 23:08

      128

      Note:
      My server is also PHP CURL enabed, safe_mode=off, and works well in integrating facebook API with PHP.
      I really need this twitter API script, and your script is the only script that successfully displaying twitter user data on Callback, but fail sending post to twitter.
      Hope you help me fix this.

      0
  • Francis

    Wednesday, November 30th, 2011 05:27

    126

    Great tutorial, I’m planning to develop my own twitter API and this one is a good example to start for. Thanks for sharing.

    0
  • sonu

    Wednesday, November 16th, 2011 12:23

    125

    I want to upload image on twitter account with php code can anyone help me regarding this.

    Thanks for this

    0
  • priya

    Saturday, November 5th, 2011 09:51

    123

    Hi
    we get user name of the person through this code
    $username = $twitterInfo->screen_name;

    but i dont know how to get email id of him

    will please answer?

    0
    • Alex

      Tuesday, April 10th, 2012 08:08

      147

      print the whole array as take what you required.
      i.e
      print_r($twitterInfo);

      0
  • Umer

    Wednesday, October 26th, 2011 13:10

    122

    Nice post but even in your demo once i refresh the page, my user info including picture goes off and it does not retain the session. Kindly comment and update your code to make it complete teaching beginners to retain user info as well.

    0
    • Abhishek Bhardwaj

      Friday, November 11th, 2011 23:18

      124

      This was a basic tutorial without any databases involved (Yes, you’ll need a database to retain sessions).

      0
  • Nilesh

    Sunday, October 23rd, 2011 23:38

    121

    Really good documentation specially for beginners.

    0
  • Daniel

    Saturday, October 22nd, 2011 00:27

    120

    A snag which I ran into and remedied: don’t forget to enable the cURL extension in php.ini (uncomment extension=php_curl.dll). Otherwise you’ll run into ‘could not find **_curl_**() function’ errors.

    0
  • Kelvin Chan

    Tuesday, October 18th, 2011 20:36

    119

    great tutorial, but I can’t seem to get the oauth_token.. :(

    +1
  • Micky

    Thursday, October 13th, 2011 03:10

    118

    Hey, get rid of the space in update.php in line 17. There are 2 spaces in that line, just delete one of them.

    0
  • evan heminger

    Tuesday, October 11th, 2011 23:20

    117

    What if I don’t have a website?

    0
  • motorlu panjur

    Sunday, October 2nd, 2011 23:09

    116

    is a herbal is live are you teacher systam

    0
  • ivan

    Thursday, September 22nd, 2011 20:51

    115

    I followed the instructions, step by step, but it doesn´t work fine. Twitter returns me a PIN code to put in to the app for the Authentication process ( of-band/PIN Code Authentication). This is so weird, because when I run your demo from this website, it works fine and doesn´t need the PIN code

    cheerrss!!!!!!

    0
  • Eric Libay

    Friday, September 16th, 2011 07:35

    114

    I can’t change my “Default Access type” into “Read & Write” it always turn into Read-Only..What happen to twitter.

    0
  • Mathias

    Monday, September 5th, 2011 17:06

    113

    Good tutorial

    Is there a way to use this API to check who unfollowed me in the last 48 house?

    0
  • bjesua

    Friday, July 29th, 2011 04:33

    108

    Hello, when i try to login i have this error on twitter

    This page is no longer valid. It looks like someone already used the token information you provided. Please return to the site that sent you to this page and try again … it was probably an honest mistake.

    Please can you help me or guide mi with this problem i had?
    i really need your answer thanks!

    0
  • Palak

    Thursday, July 28th, 2011 13:10

    107

    Hi,

    Thanks for nice tutorial. It helps me lot. One thing I want to ask that. I want to follow the user by this api. how it can be done ? is there any particular function in twitter lib for that ? same like
    $update_status = $twitterObj->post_statusesUpdate(array(‘status’ => $msg)); as u used this for the post to twitter.
    Please tell me how can I follow the user by this api ?

    Thanks.

    0
  • sai

    Tuesday, July 26th, 2011 13:33

    106

    the demo is working. but i downloaded and when i am accessing it is not working can u help me please.

    0
  • Ekn

    Friday, July 22nd, 2011 14:44

    104

    I got no success in trying. The link to the DEMO is broken. Could you please, update it?

    0
    • Rean John Uehara

      Friday, July 22nd, 2011 14:59

      105

      That’s odd, the demo is working fine for me and I’ve allowed 1stwebdesigner access to my Twitter account. :|

      0
  • Dan

    Thursday, June 30th, 2011 10:38

    103

    Any idea how to use this great tool in a frame? it simply does not open the sign in link within a frame. I am aware about the policy of twitter for frames but there should be way to use it.

    What is my thinking is to open the sign in link in a new window and after authenticating, the frame should refresh itself to load required page. But I couldnt manage to do it.

    any help is welcome?

    0
    • Abhishek

      Friday, September 2nd, 2011 03:57

      111

      No need to use frames. You can instead use an AJAX-jQuery method to achieve the same!

      0
  • Rupanjan

    Tuesday, June 21st, 2011 16:50

    102

    This code is working fine than the other one
    Thanx for sharing

    Rupanjan

    0
  • Kevin

    Sunday, June 19th, 2011 15:49

    101

    Where is the log out button so users can log out of your application AND Twitter?

    0
  • Usman

    Friday, June 17th, 2011 11:31

    99

    Hi,

    i m trying to use your code but no success for me. using same code as you have asked only changed my consumer keys. nothing less OR more. please see below URL why it is behaving like this.

    http://www.socialscratch.com/images/twitter-oauth/

    Waiting for your reply.

    0
  • PM

    Thursday, June 2nd, 2011 23:54

    98

    Hi,

    Thanks for sharing very helpful information. Can you demonstrate how to retrieve tweets from an account?

    Thanks again,
    -PM.

    0
  • jude

    Sunday, May 15th, 2011 16:38

    97

    HI ,

    Is it possible to include a username and password field so there is no request for authorization ?

    thanks in advance
    Jude Dcoutho

    0
    • Rean John Uehara

      Sunday, May 15th, 2011 17:38

      96

      Hi, as far as I am concerned the authorization is required by Twitter. But you can still go here to find out: http://dev.twitter.com/pages/oauth_faq

      0
    • Abhishek

      Friday, September 2nd, 2011 03:54

      110

      Twitter had closed that method of authentication last year itself.

      0
  • Lev

    Monday, May 9th, 2011 13:28

    92

    Don’t use the code posted here – it is OUT OF DATE (get it from the author directly at the URL provided below).

    I ran into a number of issues with the code provided here (the biggest being many status updates would outright fail because of accented characters).

    The same library (only newer code, with lots of fixes) can be found here:

    https://github.com/jmathai/twitter-async

    0
  • int

    Tuesday, May 3rd, 2011 12:14

    91

    My messages are not getting added to the time line.

    Is there something I should do to rectify it?

    0
    • Abhishek

      Friday, May 13th, 2011 17:32

      95

      Change your application’s access type to “Read/Write”.

      0
  • edwin

    Friday, April 29th, 2011 19:55

    90

    Is it possible to let the script login automatic so you can go to the page and fill in the tweet, instead of going to the page and login to twitter first.

    0
  • Anh

    Friday, April 29th, 2011 08:18

    89

    Great tutorial, but there’s an error. In the “secrets.php,” the variables should be $consumerKey and $consumerSecret, not $consumer_key and $consumer_secret. You have to change this in the index.php file as well. If you don’t, the oauth token won’t register.

    0
    • Abhishek

      Friday, May 13th, 2011 17:30

      93

      No need to make such changes. Those are variable names..

      0
  • Rupanjan Mukherjee

    Saturday, April 23rd, 2011 15:40

    87

    Every Thing is Understandable but my question where to put the (oauth_token ) (oauth_token_secret)
    am a newbie in this field.
    another question what will be my call back url is it http://www.xyz.com/xyz/update.php
    any body can explain?

    Thanks in advance. The topic is nice may i mistake something

    0
    • Anh

      Friday, April 29th, 2011 06:46

      88

      I’m having the same problem. I followed the tutorial exactly and I updated the secrets php script with my own keys, but it’s not “seeing” my oauth token?

      Any help would be appreciated! Thanks.

      0
    • Abhishek

      Friday, May 13th, 2011 17:31

      94

      secret.php file!

      0
  • Zach

    Friday, April 15th, 2011 22:00

    85

    Great tutorial! Very cool potential here.

    I was struggling with a goofy error, and I just figured it out. In case anyone is in the situation where you send your tweet, the page reloads, says you successfully updated your timeline, but you DON’T see anything actually update on your feed, make sure your app is registered as Read & Write under “Default Access Type”. I had mine set to Read-only, so it wasn’t working.

    I figured it out by checking the temporary variable that gets assigned the response to the update (in index.php):

    $temp = $update_status->response;

    and found [error] => Read-only application cannot POST

    Silly error. Very simple. But fooled me nonetheless. Hopefully this post will help someone else out.
    Cheers!

    0
    • Abhishek

      Saturday, April 16th, 2011 08:58

      86

      It’ll surely help people out!

      0
  • Paul

    Thursday, April 14th, 2011 12:51

    84

    Great tutorial and have got it all working nicely. Only problem I have found is when someone tried a bit of French it didn’t get posted… Très Bien.
    Doesn’t seem to like the è!

    0
  • ester

    Tuesday, April 12th, 2011 11:33

    79

    I got “….enter the following PIN to complete the process.”

    Where should I enter this PIN in order to continue with the process?
    Please, does anyone give me an answer…
    Thank you

    0
    • Abhishek

      Wednesday, April 13th, 2011 03:50

      80

      Register your application on Twitter and enter the KEY’s you get from there in the “secret.php” file!

      0
  • Rakesh

    Monday, April 11th, 2011 18:37

    78

    How can we use it to get tweek by keywords(post id ex: @cldmgc)? Atleast 10 tweeks.

    0
    • Abhishek

      Wednesday, April 13th, 2011 03:51

      81

      What do you mean by Tweaks?

      0
  • Rakesh

    Monday, April 11th, 2011 18:17

    77

    when i tried to run it it ran well but after signing in twitter took me at a page where a token was given and a message was written that “Go to and enter the following to complete the process. Can you guide me to get rid of this obstacle.

    0
    • Abhishek

      Wednesday, April 13th, 2011 03:55

      83

      Reading the tutorial properly will help you get rid of the obstacle!
      – Register your app on Twitter.
      – Enter the Key’s you get after app register in the “secret.php” file available in the enclosed source code package!

      Read the tutorial properly!

      0
  • Josh

    Thursday, March 3rd, 2011 18:23

    75

    I am getting an error when trying to run the index.php in browser:

    “Fatal error: Call to undefined function curl_multi_init() in E:\WEB FOLDERS\lib\EpiCurl.php on line 21″

    Help?

    0
    • Robin

      Wednesday, March 16th, 2011 15:41

      76

      It might be problem with cURL. Try this http://www.robinthomas.in/php/enable-curl-in-wamp/

      0
    • Abhishek

      Wednesday, April 13th, 2011 03:52

      82

      It’s indeed a problem with cURL! Also use “http://127.0.0.1″ as your callback URL when testing Twitter oAuth on localhost!

      0
  • Alesha

    Wednesday, February 23rd, 2011 16:25

    71

    I have a problem with the oauth token,
    When I try to sign in to authenticate, it does not generate an oauth token. When I hover over ‘Sign In’ this is the link:
    http://twitter.com/oauth/authorize?oauth_token=

    then I get an error from twitter, because there is no token

    can anybody help?

    0
    • Abhishek

      Tuesday, March 1st, 2011 02:14

      74

      Add your API keys to secret.php file!

      0
  • Joan Izquierdo

    Friday, February 11th, 2011 11:29

    70

    Thanks for this guide! It’s great! and now I have a problem …

    The first time it works correctly, but after the user must “Sign In with Twitter” every time :-(

    Are there solution for this problem? Thanks

    0
    • Abhishek

      Tuesday, March 1st, 2011 02:14

      73

      Yeah! use a database to store the Token information.

      0
  • Yankymetro

    Wednesday, January 26th, 2011 23:21

    67

    When I open the library file, there’s no file called index.php… Do I create it?

    0
  • Maarten Keyman

    Monday, January 17th, 2011 20:45

    66

    How to integrate the CSS from your previous tutorial with this one? Please help me!

    0
    • Abhishek

      Wednesday, February 9th, 2011 01:35

      69

      Its already integrated?

      0
  • Anonymous

    Wednesday, January 5th, 2011 23:46

    65

    Great tutorial. I can’t wait to dive into this later this evening! It will make developing my Twitter app a cinch!

    0
  • Anonymous

    Wednesday, January 5th, 2011 23:44

    64

    You’re going to have to put an authenticate link in your backend and save the oauth tokens that twitter passes back to your MySQL database. Then you can just do exactly this but get the oauth tokens from you DB instead.

    0
  • Vladimír Skoupil

    Wednesday, December 22nd, 2010 22:21

    63

    Also thanks for great tutorial.
    I’d like to ask you, if is it possible to go straight to form and directly type the tweet without prompting me to click Allow button on twitter.com…

    0
    • Abhishek

      Wednesday, February 9th, 2011 01:35

      68

      It was possible until a few days ago but they closed that method now!

      0
  • Abhishek Bhardwaj

    Thursday, December 16th, 2010 08:00

    62

    Hello folks,
    The demo is working fine for me @ http://tutorialswalk.info/demo/twitter-update-php-oauth/ I just tweeted this using that demo: http://twitter.com/#!/Abhishekwebin/status/15314744860741632
    Feel free to email me @ ‘abhishek66ster[at]gmail.com’ and I’ll walk you through the error!
    Thanks :)
    Abhishek Bhardwaj

    0
  • Zoyx

    Friday, December 10th, 2010 04:55

    61

    Same exact thing for me. Everything seems to work, but no update showing up on Twitter. Did something at Twitter get changed recently?

    0
  • Dave Lu

    Saturday, December 4th, 2010 04:39

    60

    dude… just store it in the DB.. someone mentioned it above as well, and they got it working.

    great tutorial by the way Abhishek!

    0
  • jm

    Friday, December 3rd, 2010 13:08

    59

    I’m in the same boat. Everything is working minus actually updating

    0
  • Scott

    Monday, November 29th, 2010 15:31

    58

    I have followed this tutorial and everything seems to work apart from the actual Twitter timeline being updated. The scripts all run error free and I see the message telling me the timeline has been updated but the actual Tweet doesn’t appear in my timeline. Anyone got any ideas?

    0
  • Rob

    Tuesday, November 2nd, 2010 23:17

    57

    Great tutorial!

    Hey Ross, how did you integrate this code to read value from your database and submit to twitter? I tried, but it seems to just fizzle.

    0
  • Alexwhin

    Saturday, October 23rd, 2010 21:11

    56

    I’m having the same issue :/

    0
  • Kevincornett

    Saturday, October 23rd, 2010 05:05

    55

    Perhaps I’m doing this wrong. When I click the log in with twitter link, I get an HTTP500 error page. I thought I had followed the directions to the letter. Any ideas?

    0
  • Ross

    Friday, October 22nd, 2010 22:42

    54

    This is a brilliant script and I have it all working and running periodic updates from my database :)

    I have a problem though! Whenever I include the pound symbol (£), it fails! The response I get is “Invalid signature” which doesn’t make sense as it works fine any other time. I’ve tried the different codes for the symbol and putting it through various string converters but no luck.

    Any ideas?

    0
  • Terri Ann

    Friday, October 22nd, 2010 05:30

    52

    Fantastic tutorial – I really appreciate your posting the example. I’ve been having a heck-of-a-time with oAuth but that download made a new project move so much faster! Too bad you didn’t include passing the callback URI in the demo. I’ll have to go and add that in. I hate relying on the value I set in the application setup – a bad practice IMHO.

    Thanks again!

    0
  • Peter

    Friday, October 15th, 2010 15:36

    51

    Many thanks for the tutorial. It works!

    0
  • phillNub

    Friday, October 8th, 2010 22:06

    50

    hi, I am having trouble setting this up for my website, basically what I need to do is send a tweet when there has been new values added to a mysql database.

    there does not seem to be anything on the web that tells me that?

    please help!

    0
    • Balaji

      Sunday, February 27th, 2011 20:42

      72

      me too have the same problem :(

      0
  • Gerri

    Sunday, October 3rd, 2010 21:53

    49

    The questions I have is, how do I set up something so that readers on one of my sites can auto install twitter backgrounds using oAuth. If it is easier for you, you can just send me an email. Your help would be much appreciated.

    0
  • Jeffrey Bennett

    Wednesday, September 29th, 2010 02:00

    47

    Hi there! Your demo URL sends me to a page that says “This Account Has Been Suspended”. I would love to see it up and running! Thanks! :)

    0
    • Abhishek

      Friday, October 1st, 2010 07:37

      48

      Hey, Sorry for the downtime! It was due to a stupid error made by my hosting provider. The tutorial demo is now back up and you can see it running. Sorry once again for the inconvinience!

      0
  • Jeff

    Tuesday, September 28th, 2010 11:33

    46

    Hi Abhishek,

    I have used your module for one of my site and it works great on my local pc which has PHP 5.2.9, however, when I use in live server having PHP 5.1.6, the thing is not working.

    I have updated the secret.php for live site as it required, however, in step 1 it self, it does give me like http://twitter.com/oauth/authorize?oauth_token=

    means something is going wrong. Can you please help for this since i am trying it from last 2 days.

    Jeff

    +2
  • Mike the Pike

    Wednesday, September 22nd, 2010 20:41

    45

    Hi just wondering if you have ever pulled posts out fo twitter for website consumption with this. I got this working no problem but really what I want to do it more a twitter2html thing although it uses basic authentication.

    0
  • Sebastien

    Thursday, September 9th, 2010 22:10

    37

    Hey,

    Thanks a lot of this write up. I don’t know why but for some reason oAuth just confuses the heck out of me and this helped quite a bit.

    I do have a question though :) I need each call to have a custom callback page to identify our clients. I know this is possible because near the callback input on the twitter application settings page it explains that I can do so by including a oauth_callback. I tried poking around in your code to see if this was supported somehow but I can’t seem to find it. I have my fingers crossed that you’ll tell me I just need to include it in some sort of parameters array so one of the constructors :)

    Any help would be appreciated and thanks again :)

    0
    • Sebastien

      Friday, September 10th, 2010 17:20

      38

      For anyone that might have the same problem as me, I solved it by using the code found here: https://docs.google.com/View?docID=dcf2dzzs_2339fzbfsf4

      It’s very similar to the tutorial here (though not explained as well, you might have to dig a little in the code and read his documentation file) but it clearly shows how to define your callback when you request a token. This would allow you to pass along GET variables or go to different domains (which is how I identify clients)

      HTH!

      0
      • Abhishek Bhardwaj

        Sunday, September 12th, 2010 08:08

        42

        Ya, Abraham’s Twitter oAuth library is more user and feature friendly! Jaisen’s library doesn’t supprt that well. There are some tutorials out there on Abraham’s library too which can be found here: http://wiki.github.com/abraham/twitteroauth/links

        0
  • Endolino

    Wednesday, September 8th, 2010 14:44

    36

    Hello,
    reading your tutorial will drop some errors in my mind. In my application i wanna only send messages to my twitter account avoiding endless login in with username and password.
    Where i am be able to get the secret password which i can put into the constructor as 3th and 4th argument?

    0
    • Abhishek Bhardwaj

      Sunday, September 12th, 2010 08:01

      40

      Store your tokens and other login credentials in your database!

      0
      • Cristian

        Saturday, September 18th, 2010 16:56

        44

        Please give me a real example (code please!!!) because I’m new in PHP…
        Thank you,
        Cristian

        0
  • robbie

    Tuesday, September 7th, 2010 02:01

    35

    Hello … just to give my gratitude at first when i saw this tutorial … i passed it up because it looked very technical …but as the hours passed and the frustration kicked in i came back across … and its brillant exactly what i have been looking for….. BUT of course always a but…. when i follow all the instructions and upload the files i get this parse error ….

    Parse error: syntax error, unexpected T_CONST, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or ‘}’

    … on line 4 of the EpiCurl.php file ….HELP i checked the Phpinfo of my site i have curl enabled and it is quite a late version . Any help would be super appreciated

    +1
    • Abhishek Bhardwaj

      Sunday, September 12th, 2010 07:56

      43

      That means that your server has PHP4. This application just works in PHP5!
      But if you have PHP5 then either the cURL extension on that isn’t installed or it isn’t configured properly.

      -1
  • Marcus

    Friday, September 3rd, 2010 17:55

    33

    Thanx for this great tutorial!!!
    I´ve been looking for a long time for a code like this!

    0
  • Mark

    Sunday, August 22nd, 2010 10:28

    31

    Thanks to you and Jaisan for all the great articles on the Twitter API…
    I seem to missing something, it seems that I can only access twitter by starting from scratch and fails the tokens on repeated access, part of which you may have touched on above about token lives. My question would be is it possible to create an application that can be called as a stand-alone and update my Twitter account without repeating the Twitter authorization each time? (Application would create the new tweets). Would the application have to use basic (curl) login to Twitter prior to creating the access tokens?

    0
  • bharath

    Sunday, August 15th, 2010 16:07

    30

    Thank You i was searching for this in many places you teached me very easily
    Thanks ………..

    0
  • cheza

    Tuesday, August 10th, 2010 09:19

    28

    Hi,

    just out of curiosity. How do you verify a user, once you have all the needed tokens, if he revisits your page. Clearly you’d have to – somehow – identify that visitor als the one specific user.

    Actually, in my opinion, at that point you won’t get around asking for twitter screen name and password, which you will have to compare to other screen names and pws which will have to be stored in your DB. => All bonuses of oauth are gone by then… I am currently stuck at that point in developing a twitter app.

    It would be nice if you could point me in the right direction! (even though I am developing with RoR instead of PHP :)!)

    thanks cheza

    0
    • Abhishek Bhardwaj

      Sunday, September 12th, 2010 07:59

      39

      That can be done using a database.
      You’ll have to store the login credentials & tokens in your database. Then if a user revisits the page, you can identify him using the tokens & credentials.

      0
    • Terri Ann

      Friday, October 22nd, 2010 05:34

      53

      After the user verifies with Twitter and the token is passed back the these two lines hold the key to what you need to store in the database:

      $_SESSION['ot'] = $token->oauth_token;
      $_SESSION['ots'] = $token->oauth_token_secret;

      Those two values are used again here:

      $twitterObj->setToken($_SESSION['ot'], $_SESSION['ots']);

      Before posting the status update. Replace the setting of the session super global with any kind-of database set and get functionality and you will be on your way. Everything you need is in that index.php file!

      0
  • freak

    Sunday, August 8th, 2010 23:32

    27

    It doesn’t generate a oauth_token for me, I have edited the secret.php but it doesn’t work. I’m using a .in domain from securesignup.net, site is hosted on 0fees.net.

    0
  • neko

    Sunday, August 1st, 2010 03:01

    25

    hello.
    your tutorial so easily to understand!
    thank you so mach.

    but i have a problem.
    i try to tweet in japanese,status is incorrect.
    In english , status is OK.

    i think encode problem.
    how can i solve ?
    please help me.

    0
    • Neko

      Thursday, August 5th, 2010 12:12

      26

      I solve that.
      I try to make original script,so I can tweet in multibyte(japanese).
      thank you!

      0
      • Abhishek Bhardwaj

        Sunday, September 12th, 2010 08:05

        41

        Glad that you could find the solution yourself!

        0
        • Petra

          Sunday, February 19th, 2012 17:21

          138

          Hi, I’m having the same problem here, I’ve been told that some of my followers can’t read the tweets in multibyte letters. If either of you can help me in any way, I would be grateful. Thnx :D

          0
  • Rims

    Thursday, July 29th, 2010 12:51

    23

    Hello… i have used the same code in my php project bcz i want to run it on localhost.
    I have also registered application in twitter and changed the secret.php file. but then also i m getting error….
    Call to undefined function curl_multi_init() in C:\Program Files\xampp\htdocs\twitter\lib\EpiCurl.php on line 21.

    Plz tell me how to resolve this error.
    I have searched about it there is no prob with PHP installed bcz it is giving information when i call function phpinfo();.

    0
    • Abhishek

      Friday, July 30th, 2010 19:48

      24

      The problem is that you do not have cURL extension installed (or it is disabled).
      Reconfigure it and it should work!

      0
  • seddik

    Friday, July 23rd, 2010 16:44

    20

    this tutorial helped me really much but just one thing i didn’t understand, for the callback url, I tried http://localhost/twitter/index.php but at twitter application settings it doesn’t accept this url ?

    0
    • Abhishek Bhardwaj

      Saturday, July 24th, 2010 22:32

      22

      lol Sorry, I think Twitter doesn’t accept any URL which doesn’t have a .com or .net or all those other domain suffixes.

      0
  • drooh

    Wednesday, July 21st, 2010 00:32

    19

    I dont understand, everytime I have to click to sign in authenticate with twitter? It would be nice to just do that once and not have to do it every time you wanted to post to twitter.

    0
    • Abhishek Bhardwaj

      Saturday, July 24th, 2010 22:30

      21

      That’s because I am not storing the token keys anywhere. This is just a simple app! Maybe in the future, I’ll have another tutorial on 1WD that connects to a database and stores the authentication keys so that the user doesn’t have to login again and again!!

      0
      • Jim

        Thursday, August 12th, 2010 12:53

        29

        It would be awesome if you could add it to this tutorial any time soon.
        Thank you very much

        0
    • Francesco

      Thursday, September 2nd, 2010 19:27

      32

      Hi drooh,
      I have your same problem.
      have you solved?

      tnx

      0
  • yankymetro

    Saturday, July 17th, 2010 03:27

    17

    I don’t know what’s the callback URL. It’s hard. Explain it to me better. Thanks.

    0
    • Abhishek

      Saturday, July 17th, 2010 21:50

      18

      Do you really think its hard? Check the first screenshot and that’s your answer otherwise the callback URL is: http://your-website.com/“”index.php”" ……..

      0
  • SG

    Wednesday, July 14th, 2010 20:22

    15

    Great post!

    Can you also tell us how to test it locally? I want to develop and test an app locally before uploading it. What should be the web / callback URL for this and how should localhost / server handle it?

    Thanks a lot.

    0
  • Jordan Walker

    Wednesday, July 14th, 2010 14:52

    14

    Wow, excellent tutorial with very detailed instruction.

    0
  • Zachary Collins

    Wednesday, July 14th, 2010 04:42

    12

    Hey there,
    Great tutorial! Only problem I am having is when I connect my account and it brings me back to the index.php page, I refresh, and it doesnt load the user.

    Thanks,
    Zachary Collins

    0
    • Abhishek

      Wednesday, July 14th, 2010 10:55

      13

      Check your callback URL on Twitter, and did you change the API Keys in secret.php file?

      0
      • Carter Thayer

        Tuesday, September 7th, 2010 02:15

        34

        I checked both, the refresh problem is still happening. Let me know if you find a solution. Also, same thing is happening on your demo page.

        0
  • Rvarm1

    Tuesday, July 13th, 2010 06:51

    10

    Hi! I was making a similiar application, but whenever I clicked sign in with twitter, it gave me this error:
    “Woah there!
    This page is no longer valid. It looks like someone already used the token information you provided. Please return to the site that sent you to this page and try again … it was probably an honest mistake.”

    Can you please help me? I already tried resetting the keys, but it didnt work.

    Thanks for your help!

    0
    • Abhishek

      Tuesday, July 13th, 2010 08:29

      11

      I think the tokens are valid for only 2 minutes. Everytime you open your oAuth app, the application connects to the API and gets your token automatically..try refreshing the page and clearing your cache + cookies, it should work..

      The error you are talking about ignites when your token has expired..and most times its due to the fact that someone else used that..after all there are 1000s of Twitter oAuth apps running on the web and these tokens are distributed among everyone! :D

      0
  • Siddharth

    Monday, July 12th, 2010 21:10

    7

    hey thats wonder tutorial..
    am actually using these.. and could u say..
    in case i we want to use these if the user s not online.. but registered..
    how to get and store the oauth token and secrets ?
    and how to ue them again to update the satus ?/
    can u help me out ?

    0
    • Abhishek

      Monday, July 12th, 2010 23:56

      4

      That can be done using a database which stores all tokens! I also emailed you from your website so I guess we should continue our conversation there :D

      0
  • Jaisen Mathai

    Monday, July 12th, 2010 23:46

    3

    I added this article to the readme of the Twitter-Async library on Github.

    http://github.com/jmathai/twitter-async

    Thanks for the write up.

    0
    • Abhishek

      Tuesday, July 13th, 2010 04:23

      8

      Thanks for adding it :)

      0
  • ditatompel

    Monday, July 12th, 2010 12:52

    2

    Nice tutorial! Thank you for sharing! =)

    -1
    • Abhishek

      Tuesday, July 13th, 2010 00:00

      5

      Thank you!! :)

      0
  • Irina

    Monday, July 12th, 2010 12:35

    1

    Great tutorial! Thanks. I just wanted to make a similar app :)

    0
    • Abhishek

      Tuesday, July 13th, 2010 00:03

      6

      Glad you liked it :)

      0
  • Abhishek

    Tuesday, July 13th, 2010 00:01

    9

    Yes, It initially looks difficult but its relatively easy once you dive into the code.

    +1

Comments are closed.

54.234.60.133 - unknown - unknown - US