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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:32:04+00:00 2026-05-27T23:32:04+00:00

I am trying to pull a JSON object from another page and then break

  • 0

I am trying to pull a JSON object from another page and then break it into pieces and values to my php document’s variables and populate the page with them.

The issue I am running into is that while the curl_exec call prints the JSON object, I cannot do anything to it from that point on. Below is my code:

$json_url = "localhost:8080/query";
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); 
curl_setopt($ch, CURLOPT_URL, $json_url);
curl_setopt($ch, CURLOPT_USERPWD, $user.":".$pass);  
$result = json_decode(curl_exec($ch));
var_dump ($result);

$curl_errno = curl_errno($ch);
$curl_error = curl_error($ch);

curl_close($ch);

// ON SUCCESS

$json_a =  $result[10];
var_dump ($json_a);

Here is a sample of a piece of the result:

 ["4"]=> array(2) { [0]=> int(1325003843) [1]=> array(2) { [0]=> int(47) [1]=> array(17) { [0]=> array(2) { [0]=> int(0) [1]=> int(1) } [1]=> array(2) { [0]=> int(17) [1]=> int(44) } [2]=> array(2) { [0]=> int(3) [1]=> int(4) } [3]=> array(2) { [0]=> int(3) [1]=> int(4) } [4]=> array(2) { [0]=> int(3) [1]=> int(4) } [5]=> array(2) { [0]=> int(3) [1]=> int(4) } [6]=> array(2) { [0]=> int(3) [1]=> int(4) } [7]=> array(2) { [0]=> int(3) [1]=> int(4) } [8]=> array(2) { [0]=> int(3) [1]=> int(4) } [9]=> array(2) { [0]=> int(3) [1]=> int(4) } [10]=> array(2) { [0]=> int(3) [1]=> int(4) } [11]=> array(2) { [0]=> int(3) [1]=> int(4) } [12]=> array(2) { [0]=> int(3) [1]=> int(4) } [13]=> array(2) { [0]=> int(2) [1]=> int(3) } [14]=> array(2) { [0]=> int(2) [1]=> int(3) } [15]=> array(2) { [0]=> int(2) [1]=> int(3) } [16]=> array(2) { [0]=> int(2) [1]=> int(3) } } } }

The var_dump ($result); returns int(1) and the other var_dump returns NULL. The curl_exec actually prints the JSON object, so I know tat it is at least grabbing it. Thanks so much for any help you might offer!

  • 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-27T23:32:05+00:00Added an answer on May 27, 2026 at 11:32 pm

    You could also just do something like

    $json_url = "localhost:8080/query";
    // $protocol should be the protocol used, ie. 'ftp://', 'http://' or 'https://'
    //  to produce an URL like 'ftp://user:pass@localhost:8080/query'
    $result = file_get_contents($protocol . $user.":".urlencode($pass) . '@' . $json_url);
    
    if($result !== false) { // ON SUCCESS
      $result = json_decode($result, true);
      var_dump ($result);
    
      if(isset($result[10])) { // If index 10 of $result exists
        $json_a =  $result[10];
        var_dump ($json_a);
      }
    } else {
      // error occured
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to pull text from another page (ajaxuseradd.psp) which is in JSON
I've generated some JSON and I'm trying to pull it into an object in
I'm trying to pull JSON data from another source by using the jquery.get method.
I'm currently trying to pull the wall from this event page: https://www.facebook.com/event.php?eid=139373546157232 , but
Trying to pull info from one JSON datafeed and use that to make another
I am trying to pull information from another site. When I try and do
i'm trying to write a simple app with node.js to pull some json from
I'm trying to pull two values from this Dictionary, But the values I'm getting
I'm trying to pull the content from the following Facebook page: https://graph.facebook.com/100000123344690/feed I'm already
I'm trying to pull a gzipped json file from http://api.discogs.com/release/339901 . I have https://github.com/waveto/node-compress

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.