0

I am using CURL function in php. i get json data from 8080 port , but return only empty value.. how to get json data from 8080 port below the link are using in CURL functions...

<?php 

$url = 'https://example.com:8080/getdata/?format=json';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headr);  
curl_setopt($ch, CURLOPT_PORT, 8080);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

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

?>
Vishnu
  • 1
  • 1
  • you use CURLOPT_RETURNTRANSFER, maybe the problem is that you're simply not printing $result ? what do you get if you add `var_dump($result);` after `$result = curl_exec($ch);` ? – hanshenrik Aug 27 '18 at 08:46
  • yes i use echo $result or var_dump($result) .But not show output only return empty value...! – Vishnu Aug 27 '18 at 11:53
  • then what does CURLOPT_VERBOSE tell you? if it tells you nothing, that means you can't see STDERR info for some reason, so add `curl_setopt($ch,CURLOPT_STDERR,STDOUT);` and re-run it. (this will redirect curl's stderr to stdout, which should enable you to view it) – hanshenrik Aug 27 '18 at 13:41
  • hanshenrik, I am using `curl_setopt(CUR_STDERR,$stdout);` . this is functions not working. And I try another method `curl_setopt($ch,CURLOPT_FOLLOWLOCATION ,true )`, also not workng .Return only empty value. Please update any other idea ... – Vishnu Aug 28 '18 at 11:57
  • what is $stdout ? what does `var_dump($stdout);` return? – hanshenrik Aug 28 '18 at 12:13
  • first i try `curl_setopt($ch,CURLOPT_STDERR,STDOUT);` this code error , than find related solutions and use `curl_setopt(CUR_STDERR,$stdout);` . `$stdout` is file elements. get from [link](https://stackoverflow.com/questions/8868808/make-curl-output-stderr-to-file-or-string). – Vishnu Aug 28 '18 at 13:29
  • weird, are you running a *very* old version of PHP? like PHP 5.2 from 2006? because `STDOUT` should work from PHP 5.3 (released in 2009) and newer.. – hanshenrik Aug 28 '18 at 13:47
  • localhost server is running in my machine. An only live server is not running ... – Vishnu Aug 29 '18 at 05:49
  • and what does `` return? – hanshenrik Aug 29 '18 at 17:43

0 Answers0