1 Replies - 1301 Views - Last Post: 07 December 2012 - 08:20 PM Rate Topic: -----

#1 itsjimmy91  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 77
  • Joined: 19-January 11

PHP to Twitter Using oAuth

Posted 06 December 2012 - 05:12 PM

Hey guys. I have a PHP website and on one page there is a link that allows a user to approve the use of their Twitter account via oAuth. The link works and correctly sends a user to the Twitter page where they need to approve the access, but I am running into a couple of things that I am not quite sure how to fix. I'm pretty new to PHP and have never worked with oAuth or the Twitter API before.

My problem is, instead of redirecting back to another page (if they did grant access), the Twitter page simply displays the user with a PIN and says that they have to enter the PIN in the app to finalize the approval process. Is there a way to completely bypass this PIN thing and once they choose approve, just send them to another PHP page?

Also, is there a way that I can send them to one page if they Approved access and another if they Denied?

Thanks.

Is This A Good Question/Topic? 0
  • +

Replies To: PHP to Twitter Using oAuth

#2 itsjimmy91  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 77
  • Joined: 19-January 11

Re: PHP to Twitter Using oAuth

Posted 07 December 2012 - 08:20 PM

I figured out how to get the redirect. Now I'm stuck on another problem. Here is the code I'm stuck with.

$oauth_token = $_GET['oauth_token'];
        $twitterObj->setToken($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;
        
        $resp = $this->twitterObj->get_search(array('geocode' => '40.757929,-73.985506,25km','rpp' => 10));
        for($i = 0; $i < count($resp); $i++){
            echo "$i";
        }



$oauth_token is set at this point. With the echo, I'm just trying to print out all of the Tweet ID's just to see if it's actually working. The problem is nothing actually gets printed out, and I'm not sure why.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1