简体   繁体   中英

PHP curl issue loading blank page

I'm trying to get a table to display through this snippet of php and I can't seem to get it to show up. It loads a blank page. When I go to the URL itself, it loads the template, but wanting to pull the table from the URL and display using php.

Can someone give me some direction?

Here is the code

<?php
$handle = curl_init();
curl_setopt ($handle, CURLOPT_URL," https://api.aghost.net/api/futures/index.cfm/");
curl_setopt ($handle, CURLOPT_POSTFIELDS,     "username=E006520104&password=KRKwev!96&service=table&symbols=@LE6,@GF6,@KW6,@C6,@S6&style=6&layout=grouped&tableWidth=350px&fontSize=0.65em&firstColLabel=Month&oddRowBgColor=%23EAEAEA&columns=high,low,last,change&commRowBgColor=%23009900&commRowTextColor=%23FFFFFF&labelTextColor=%23009900&exchangeByComm=1");
curl_setopt ($handle, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt ($handle, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt ($handle, CURLOPT_FRESH_CONNECT, TRUE);
curl_exec ($handle);
curl_close($handle);
?>

Try this ->

<?php
$handle = curl_init();
curl_setopt ($handle, CURLOPT_URL,"https://api.aghost.net/api/futures/index.cfm/");
curl_setopt($handle,CURLOPT_POST, 1);
curl_setopt ($handle, CURLOPT_POSTFIELDS,     "username=E006520104&password=KRKwev!96&service=table&symbols=@LE6,@GF6,@KW6,@C6,@S6&style=6&layout=grouped&tableWidth=350px&fontSize=0.65em&firstColLabel=Month&oddRowBgColor=%23EAEAEA&columns=high,low,last,change&commRowBgColor=%23009900&commRowTextColor=%23FFFFFF&labelTextColor=%23009900&exchangeByComm=1");
curl_setopt ($handle, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt ($handle, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt ($handle, CURLOPT_FRESH_CONNECT, TRUE);
$output = curl_exec ($handle);
curl_close($handle);
echo $output;
?>

if it still do work maybe the website you curling to requires useragent varification. In that case use CURLOPT_USERAGENT .

When you have the option CURLOPT_RETURNTRANSFER set to true curl_exec will return the resulting data instead of dumping it out.

Returns TRUE on success or FALSE on failure. However, if the CURLOPT_RETURNTRANSFER option is set, it will return the result on success, FALSE on failure.

Either set CURLOPT_RETURNTRANSFER to false or store and print the results after you receive it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM