adobe photoshop 60 download

Adobe Premiere Pro CS5 discount free adobe dream weaver 8 download free download adobe distiller cheapest adobe photoshop free download full version where does adobe save download video files

adobe bridge download

Adobe Creative Suite 4 for Mac buy cheap download adobe photoshop elements 5 adobe download free premiere pro buy cheap adobe acrobat 8 download purchase adobe photoshop cs3 extended full download

free adobe download manager

buy cheap Adobe cs5 Design Premium for Mac adobe acrobat reader 6 0 1 free download adobe flashplayer download softpedia discount download adobe after effects download adobe after effects

free download adobe illustrator 9

cheapest Adobe cs5 for Mac adobe cs2 download free crack key generator how to download adobe flash movies cheapest adobe acrobat reader free download adobe 8 free download

free adobe download

Autodesk AutoCAD cheapest adobe download free premiere adobe distiller free download discount download adobe flashplayer free adobe download manager download

adobe audition 1 5 download

cheap AutoCAD Architecture adobe acrobat 8 free download adobe creative suite 2 download cheapest download adobe premiere pro cs3 download adobe reader cd

adobe encore menu download

cheapest Adobe Captivate CS5.5 download adobe ebook reader adobe photoshop elements 3 for mac download cheap download adobe photoshop 7 download adobe flash player

download adobe reader latest version

discount Creative Suite 5.5 download adobe photoshop cs2 adobe photoshop 8 free download full version discount download free adobe standard adobe flas player 9 download

download adobe photoshop mac free

Autodesk AutoCAD discount free adobe 8 download free download of adobe pagemaker buy cheap adobe dream weaver 8 download download adobe scanner

adobe reader download for mac

discount AutoCAD 2010 free adobe download free download of adobe reader buy cheap free download adobe photodeluxe home edition adobe flash player 8 download

adobe lightroom download

AutoCAD LT 2012 buy cheap adobe golive cs2 download freeware adobe acrobat download cheap adobe flash activex download download adobe flashplayer

adobe flash 9 download

adobe acrobat x buy cheap adobe free download software download adobe photoshop cs2 cheap download adobe audition 3 free adobe premiere download

adobe flash offline download

adobe creative suite 5 discount download adobe acrobat reader 8 adobe 9 download discount free adobe photoshop elements 6 download download adobe reader pdf free

search adobe reader 7 0 download

cheap adobe cs5 adobe acrobat writer free download adobe fine reader free download cheap adobe player download center adobe professional download

download adobe flashplayer free

Adobe cs5 Design Premium cheapest where free download adobe acrobat free download of adobe reader buy cheap adobe flash 7 download download adobe reader8

free adobe acrobat writer download

Adobe eLearning Suite cheap download adobe active x download adobe acrobat 7 updates discount download adobe flash 9 for h264 free adobe pdf maker download

adobe photo plus 6 download

discount Adobe eLearning Suite 2 download adobe photoshop cs2 adobe illustrator full crack download cheapest adobe photoshop download site adobe acrobat raeder v7 download

adobe flash player download for windows vista

discount Adobe Flash Catalyst CS5 adobe photo editor download adobe reader 6 free download discount download adobe flashplayer free free download adobe illustrator 9

adobe shockwave player download

discount Adobe Indesign CS5 free adobe dream weaver 8 download adobe photo free download cheapest adobe flash player downloader free download hunter grabber free adobe profesional 8 download

adobe type manager download free

discount Adobe Photoshop CS5 download adobe acrobat reader free old adobe software download discount download adobe flash player stand alone adobe acrobat update download

Twitter OAuth Integration using PHP

This article would help you to integrate twitter using OAuth . I had to implement twitter integration using OAuth but couldn’t find a good tutorial but did it successfully after long research. Thus I am sharing you step by step explanation on it .

Step 1 : Login to your twitter account and register a new application .
It’s under Settings > Connections > Developers
OR
Follow the link http://twitter.com/apps

Register you application using application name and a logo.
Select Application Type : Browser.
Default Access Type : Read & Write.
Use Twitter for Login : Activate the check-box.
Set Callback URL to http://www.myapplicationname.com/index.php .
The application redirects after successful authentication to callback URL specified.

After registering the application you would get a Consumer Key and Consumer Secret key as shown below .

Step 2 : Download twitter client library from here

Step 3 : Edit secret.php with the new Consumer key and Consumer secret .

Step 4 : Create a file named index.php and add the following code.

Source code of : index.php


<?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-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;

 echo "Twitter Handle : ".$username; echo '<br />';
 echo "Profile Picture : <img src='$profilepic' /> ";
 echo "<br /><br />";
 echo "<label>Update Twitter Timeline</label>";
 echo "<form method='post' action='index.php'>";
 echo "<input type='text' name='tweet' id='tweet' />";
 echo "<input type='submit' value='Tweet' name='submit' id='submit' />";
 echo "</form>";
 }
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>";

}

?>

You are done !

I have packed all basic features into a single file you can use it in separate file if needed .
Hope the tutorial helped you !

You can download the complete application code here

Leave a comment if u need any help .

About the Author: a holistic web developer , movie buff and technical blogger from queen of arabian sea.

RSSComments (25)

Leave a Reply | Trackback URL

  1. Thanks !
    i test your code, is great !

    thanks a lot.

    MP

  2. anoopsachari says:

    Thank you Mariano .

  3. Rodrigo says:

    Olá como faço para postar alguma mensagem no twitter do meu usuario quando ele enviar alguma informação ?

    Preciso armazenar algum retorno do twitter no banco de dados quando ele aceitar minha integração ?

    Obriagdo !

  4. Kluchy says:

    Sup

    Thanks a mil man, epic code helped me a lot no hassles .

  5. Logesh Paul says:

    Great article! Keep this coming :)

  6. anoopsachari says:

    Thank You @Logesh

  7. anoopsachari says:

    Thanks a lot … @Logesh

  8. Hi Anoop,

    Thanks for the update Buddy! :) I really needed this! especially with the pics! :)

  9. alienmau says:

    hi, im using this but i get an error:

    Undefined index: port in EpiOAuth.php
    Undefined variable: args EpiTwitter.php
    A session had already been started – ignoring session_start() in /EpiOAuth.php

    so what you suggenst???

  10. Ji Anoop,

    thanks for this, very well explained, had to retweet you now :P

  11. Carlos says:

    Hi, I see your application very helpful I tried to use it but I got this errors

    Notice: A session had already been started – ignoring session_start() in /…/lib/EpiOAuth.php on line 2

    Notice: Undefined index: oauth_token in /…/index.php on line 9

    Notice: Undefined index: port in /…/EpiOAuth.php on line 146

    Fatal error: Call to undefined function hash_hmac() in /…/EpiOAuth.php on line 195

    would you help me please!!!!

  12. anoopsachari says:

    @carlos . i did not find error executing the code. i think you have some error creating session.

  13. Carlos says:

    I fixed some errors but still got this one

    Notice: Undefined index: oauth_token in C:\…\index.php on line 9

    and I had another trouble, and is that the application seems to be in a cycle, I mean. I click on the buttom sign on twitter, after that, go to my applicattion, click on allow and finally it must be on the message page but don´t it came back to the button sign in on twitter why this happen???

  14. Carlos says:

    Forget I solved it, but now this happens

    Fatal error: Call to undefined function json_decode() in /…/tweets/lib/EpiTwitter.php on line 95

    How can I put the json on the code???

  15. anoopsachari says:

    @carol . update the php version . old php versions does not support json .

    could you pls post how you solved the other issues .

  16. Carlos says:

    Well the oauth_token issue happens cause I pass a variable in $_POST and it is $_GET, the port was for an undeclared array();

    HOw can I do it without touching the server???, Cause I can´t

  17. anoopsachari says:

    oh! u dont have access to your server to update php @carols .

  18. Carlos says:

    I have a cuestion Why always the application ask for permission…. everytime I run the application twitter shows me the allow, deny page If I allow it once! why I have to do it again???..

  19. anoopsachari says:

    @carols a good qns . use getAuthenticateUrl(); instead of getAuthorizationUrl(); also download the latest updated lib from http://www.jaisenmathai.com/articles/twitter-php-oauth.html

  20. I need your help to integrate Twitter Oauth to my website, please email me your cost and time to do this job. Thanks

  21. Amira Illas says:

    Excellent article indeed. My teacher has been waiting for this content.

  22. jothirajan says:

    Nice/ Handy / Clear code

  23. pandikamal says:

    hi,
    i have created the twitter application.

    i am getting the errors the following errors

    Notice: Undefined index: oauth_token in D:\wamp\www\twitter\index.php on line 8

    Notice: Undefined index: port in D:\wamp\www\twitter\lib\EpiOAuth.php on line 146

    Please help me.

  24. Santhosh says:

    Hi Anoop Achari,

    Great of your article with helpful suggestion.
    I liked your article and explanation.
    I am working as a PHP Web developer.
    If i have any technical doubt can contact through mail.

  25. Rani Y says:

    Hi Anoop,
    plz can u provide some help for ‘Twitter OAuth using Javascript’? Specially on the following issues:
    1. When we want to use our own button for Login and not the regular ‘Sign in with Twitter’ button provided
    2. Sign Out functionality
    3. When we want to retrieve user info from twitter like email (which is not currently allowed directly through the API)

Leave a Reply

Get Adobe Flash playerPlugin by wpburn.com wordpress themes