Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Nov 2010
    Posts
    17
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question Need help in Twitter api (Abraham's TwitterOAuth: Could Not Authenticate You Problem)

    Well,

    I am using Abraham's TwitterOauth library to build an application that will collect oauth token and oauth token secret for each user and save it to database. So that later I can tweet on behalf of them.

    I am doing it correctly. When user clicks on Allow this Application my app is getting authorized and user is redirected to the callback. I am also getting the Oauth token and Oauth token secret. But it's not working when it comes to update status or read timeline or do anything else with user's account.

    I have read and write access in settings. My consumer keys and secret are correct.

    It says Could Not Authenticate You.. What might be the problem? Please see my code below-

    Here is the code for index.php (URL for the application):

    PHP Code:
    <?php
    session_start
    ();
    require_once 
    'twitteroauth.php';
    require_once 
    'OAuth.php';
    define("CONSUMER_KEY""My key here");
    define("CONSUMER_SECRET""my secret here");
    $to = new TwitterOAuth(CONSUMER_KEYCONSUMER_SECRET);
    $tok $to->getRequestToken($_REQUEST['oauth_verifier']);
    $request_link $to->getAuthorizeURL($tok);
    $_SESSION['oauth_access_token']= $tok['oauth_token'];
    $_SESSION['oauth_access_token_secret'] = $tok['oauth_token_secret'];
    header("Location: $request_link");
    exit;
    ?>
    Code For callback.php:

    PHP Code:
    <?php
    session_start
    ();
    require_once 
    'twitteroauth.php';
    require_once 
    'OAuth.php';
    define("CONSUMER_KEY""My Key");
    define("CONSUMER_SECRET""My Secret");
    if ((!isset(
    $_SESSION['oauth_access_token'])) || ($_SESSION['oauth_access_token'])==''
    {
    $to = new TwitterOAuth(CONSUMER_KEYCONSUMER_SECRET$_SESSION['oauth_request_token'], $_SESSION['oauth_request_token_secret']);
    $token_credentials $to->getAccessToken($_REQUEST['oauth_verifier']);
    $_SESSION['oauth_access_token'] =$token_credentials['oauth_token'];
    $_SESSION['oauth_access_token_secret'] = $token_credentials['oauth_token_secret'];
    }
    $to=new TwitterOAuth(CONSUMER_KEY,CONSUMER_SECRET,$_SESSION['oauth_access_token'],$_SESSION['oauth_access_token_secret']);
    $content $to->post('statuses/update', array('status' => 'Hello Twitter')); 
    var_dump($content);
    ?>
    It gives the following Output:

    object(stdClass)#5 (2) { ["error"]=> string(27) "Could not authenticate you." ["request"]=> string(23) "/1/statuses/update.json" }

    It says "Could Not Authenticate You"...

    Any help will be highly appreciated..

    Thanks A Lot!
    Last edited by Inigoesdr; 08-26-2011 at 08:27 PM.

  • #2
    New Coder
    Join Date
    Nov 2010
    Posts
    17
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Got the solution...


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •