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 1046261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:07:08+00:00 2026-05-16T16:07:08+00:00

I’ve followed the instructions on http://developers.facebook.com/docs/api#authorization using the standard PHP library. Everything works fine

  • 0

I’ve followed the instructions on http://developers.facebook.com/docs/api#authorization using the standard PHP library. Everything works fine until it redirects to my site. I’m not sure what I’m meant to be doing here! When the redirection occurs, I can see the key facebook talks about that I use to request an OAuth token in the URL.

However what am I meant to do with this? Do I write a simple script that takes the new ‘code’ value and place a request to the facebook page with that included in the details? Is there no call in the php library to do this entire process for me?

Any help appreciated.

  • 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-16T16:07:09+00:00Added an answer on May 16, 2026 at 4:07 pm

    Here’s how the code looks in my application (simplified for this example)

    $code = $_REQUEST['code'];
    if ( $code )
    {
      $response = $facebook->api( '/oauth/access_token', 'GET', array(
          'client_id'     => $facebook->getAppId()
        , 'client_secret' => $facebook->getApiSecret()
        , 'redirect_uri'  => 'http://example.com/your/redirect/uri'
        , 'code'          => $code
      ) );
      parse_str( $response, $vars );
      $oauthToken = $vars['access_token'];
    
      // Persist this token in the session, DB, or wherever you want
    
    } else {
      switch ( $_REQUEST['error_reason'] )
      {
        case 'user_denied':
          // some sort of message here
          break;
      }
    }
    

    If, like me, you have created a subclass of Facebook, just put some of the above into a new method

    /**
     * Exchange an Access Code for an OAuth Token
     *  
     * @param string $accessCode
     * @param string $redirectUrl
     * 
     * @return string OAuth Token
     */
    public function getOauthTokenFromAccessCode( $accessCode, $redirectUrl )
    {
      $response = $this->api( '/oauth/access_token', 'GET', array(
          'client_id'     => $this->getAppId()
        , 'client_secret' => $this->getApiSecret()
        , 'redirect_uri'  => $redirectUrl
        , 'code'          => $accessCode
      ) );
      parse_str( $response, $vars );
      return $vars['access_token'];
    }
    

    Which simplifies the client code to this

    $code = $_REQUEST['code'];
    if ( $code )
    {
      $oauthToken = $facebook->getOauthTokenFromAccessCode(
          $code
        , 'http://example.com/your/redirect/uri'
      );
    
      // Persist this token in the session, DB, or wherever you want
    
    } else {
      switch ( $_REQUEST['error_reason'] )
      {
        case 'user_denied':
          // some sort of message here
          break;
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm making a simple page using Google Maps API 3. My first. One marker
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the

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.