Receiving data in JSON with cURL

2

I'm sending a cURL, to a URL that will return a JSON response. I'm not sure how to do this, but I'm not sure how to do this, but I'm not sure how to do this. return page is blank.

How do I get the page returned in JSON? I tried something like: curlopt_followlocation, false and no success.

I have an X page, where I get the answer from page Y (where I make use of curl), on page X the return of page Y comes in HTML instead of I came in JSON, and when I say to cURL to do not follow any followlocation the page comes back blank.

I would not like to do it via AJAX, but in PHP.

    
asked by anonymous 02.04.2015 / 16:07

1 answer

3

I hope Alexander helps.

I have this script running smoothly.

$url = "http://www.url.com.br";

$ch = curl_init();

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL,$url);
$result=curl_exec($ch);

curl_close($ch);

var_dump(json_decode($result, true));

If it does not help, put the code you're trying so we can evaluate it better.

    
02.04.2015 / 16:25