Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 990929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:01:34+00:00 2026-05-16T06:01:34+00:00

I’m working on making my script mesh with OAuth instead of Basic Auth, and

  • 0

I’m working on making my script mesh with OAuth instead of Basic Auth, and I’m stuck. So far, I’m just working on authenticating at the moment, but I can’t get that working. This code:

<?php

  include 'config.php';
  include 'twitteroauth/twitteroauth.php';

  // Use config.php credentials
  $conn = new TwitterOAuth(CONSUMER_KEY,CONSUMER_SECRET);

  // Use application's registered callback URL
  // And get temporary credentials using made connection
  $tempCred = $conn->getRequestToken();

  // Use 'Sign in with Twitter'
  // for Redirect URL
  $rURL = $conn->getAuthorizeURL($tempCred);

  echo '<a href="'.$rURL.'">1. Click me first!</a><br />';

works just fine. However, when I make it to this step:

  // Build a new TwitterOAuth connection
  // Now that the app has verified credentials
  $conn = new TwitterOAuth(CONSUMER_KEY,
                           CONSUMER_SECRET,
                           $_SESSION['oauth_token'],
                           $_SESSION['oauth_token_secret']);

  // Get non-temporary credentials from Twitter
  $tokenCred = $conn->getAccessToken();

  echo '<a href="index.php">2. Click me next!</a><br />';

?>

I get a Page Not Available, Error 324 (net::ERR_EMPTY_RESPONSE): Unknown error. Is anyone familiar with this issue? I was following the documentation as closely as I could, but as I am a complete rookie I’m sure I made some stupid mistake.

Also, a follow up question: Once I do get my script authorizes via this process, what is my next step in terms of grabbing the friends feed xml? Can I just cURL it like before?

EDIT: The source for getAccessToken(); is as follows:

 function getAccessToken($oauth_verifier = FALSE) {
    $parameters = array();
    if (!empty($oauth_verifier)) {
      $parameters['oauth_verifier'] = $oauth_verifier;
    }
    $request = $this->oAuthRequest($this->accessTokenURL(), 'GET', $parameters);
    $token = OAuthUtil::parse_parameters($request);
    $this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
    return $token;
  }

And yes, config.php is correct.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T06:01:34+00:00Added an answer on May 16, 2026 at 6:01 am

    I have used this api for pin based oauth authentication for twitter. I used php simple oauth library http://php.net/manual/en/book.oauth.php.

    Here is the code if you want to see.

    
    
    class TwitterPinBasedOauth{
        private static $requestTokenUrl = 'http://twitter.com/oauth/request_token';
        private static $accessTokenUrl = 'http://twitter.com/oauth/access_token';
        private static $authorizeUrl = 'http://twitter.com/oauth/authorize';
        private static $updateUrl = 'http://twitter.com/statuses/update.json';
    
        private $twitterOauth;
        public function __construct(){
            $this->twitterOauth = new OAuth(ConsumerToken::$CONSUMER_KEY,
                                            ConsumerToken::$CONSUMER_SECRET,
                                            OAUTH_SIG_METHOD_HMACSHA1,
                                            OAUTH_AUTH_TYPE_AUTHORIZATION);
        }
    
        public function getAndStoreRequestToken(){
            $callbackUrl = "oob";
            $response = $this->twitterOauth->getRequestToken(self::$requestTokenUrl, $callbackUrl);
            print_r("REQUEST TOKEN:\n");
            print_r($response);
            print_r(PHP_EOL);
            file_put_contents(Constants::$oauth_request_file, serialize($response));
            echo "AUTH URL:\n".self::$authorizeUrl."?oauth_token=".$response['oauth_token'].PHP_EOL;
        }
        public function getAcessToken($pin){
            $request_tokens = unserialize(file_get_contents(Constants::$oauth_request_file));
            $this->twitterOauth->setToken($request_tokens["oauth_token"],$request_tokens["oauth_token_secret"]);
            $response = $this->twitterOauth->getAccessToken(self::$accessTokenUrl, NULL, $pin);
    
            file_put_contents(Constants::$oauth_access_file, serialize($response));
    
            print_r("ACESS TOKEN:\n");
            print_r($response);
            print_r(PHP_EOL);
        }
        public function updateStatus($status){
            try{
                $access_tokens = unserialize(file_get_contents(Constants::$oauth_access_file));
                $this->twitterOauth->setToken($access_tokens["oauth_token"],$access_tokens["oauth_token_secret"]);
                $this->twitterOauth->fetch(self::$updateUrl,
                                        array('status' => $status),
                                        OAUTH_HTTP_METHOD_POST);
            }
            catch(OAuthException $e){
                error_log($e->getMessage().PHP_EOL);
                return intval($e->getCode());
            }
       }
    } 
    
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 480k
  • Answers 480k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer $data["name"]=$_POST["name"] $data["email"]=$_POST["email"] $data["msg"]=$_POST["msg"] $data["origin"]=$_POST["origin"] file_put_contents("filename.txt", serialize($data)); and to bring those… May 16, 2026 at 6:03 am
  • Editorial Team
    Editorial Team added an answer From ScottGu's blog From MSDN It looks like in .NET… May 16, 2026 at 6:03 am
  • Editorial Team
    Editorial Team added an answer This is a bad idea - you should use a… May 16, 2026 at 6:03 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.