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

  • Home
  • SEARCH
  • 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 8442825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:56:45+00:00 2026-06-10T08:56:45+00:00

I have this url, but when I run the curl function, i can’t get

  • 0

I have this url, but when I run the curl function, i can’t get the access token: Any idea?

   $url =  "https://graph.facebook.com/oauth/access_token?client_id=xx16796&redirect_uri=http%3A%2F%2Flocalhost%2Fcake%2Fusers%2Flogin&client_secret=f70f01e76xxxxxebbbb9dfd7e&code=AQAD2Cfkx_RryGAQ5w5fHPelQFCOqIJRnw1gg8DGFpw..."

  /**
       * Call to Facebook to get access token
       */
      if (($response = $this->_connect($url)) !== false) {
        parse_str($response, $response);
            // i should stay here.
      }

  /**
   * Something went wrong! todo
   */
  if (empty($response['access_token'])) {
    // i am here.
    return false;
  }

 public function _connect($url)
  {
    $response = false;

    if (is_callable('curl_init')) {

      $curl = curl_init($url);

      if (is_resource($curl) === true) {
        curl_setopt($curl, CURLOPT_FAILONERROR, true);
        curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

        /**
         * Attempt to execute the session until we get a result OR
         * the number of maximum attempts has been reached
         */
        $attempts = 3;
        while (($response === false) && (--$attempts > 0)) {
          $response = curl_exec($curl);

          var_dump($curl); //resource(58, curl)
          var_dump($response); //boolean false 

        }

        curl_close($curl);
      } else {
        return false;
      }

/**
 * If cURL is not enabled, we use file_get_contents
 */
    } else {
      $response = @file_get_contents($url);
    }

    return $response;
  }
  • 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-06-10T08:56:47+00:00Added an answer on June 10, 2026 at 8:56 am

    I don’t know exactly what is the problem.

    But this works fine for me.

    public function _connect($url)
    {
        $result = false;
        $url = str_replace(' ', '%20', $url);
        $curl = curl_init($url);
    
        if (is_resource($curl) === true)
        {
            curl_setopt($curl, CURLOPT_FAILONERROR, true);
            curl_setopt($curl, CURLOPT_FOLLOWLOCATION, false);
            curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
            curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
            curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
    
            $result = curl_exec($curl);
            curl_close($curl);
        }
    
        return $result;
    }  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi have this URL string which I need to extract possibly using regex but
Sorry, but I'm new to accessing return from another domain. I have this url
Im trying to get some auto complete to work. I have this URL i
How can I hide the parameters in Codeigniter? I have this URL: http://example.com/profile/1 I
The first question is how to run a function using the URL, I have
I am using this function for my cURL queries. function get_source($url){ $ch = curl_init();
I am trying to read a URL using CURL. When I run this URL
I have this code: $('#page-refresh').click( function() { $.ajax({ url: /page1.php, cache: false, dataType: html,
I have this URL example.com/photo?people I want to rewrite this URL in the form
Let's say I have this url: www.example.com/test.php?page=4 How do i retrieve the value of

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.