我正试图通过这个php片段来显示一个表,但似乎无法显示它。它加载一个空白页面。当我转到URL本身时,它会加载模板,但希望从URL中提取表并使用php进行显示。
有人能给我指路吗?
这是代码
<?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);
?>
试试这个->
<?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;
?>
如果它仍然有效,也许你访问的网站需要用户代理验证。在这种情况下,请使用CURLOPT_USERAGENT
。
当选项CURLOPT_RETURNTRANSFER
设置为true时,curl_exec
将返回结果数据,而不是将其转储。
成功时返回TRUE,失败时返回FALSE。但是,如果设置了CURLOPT_RETURNTTRANSFER选项,它将在成功时返回结果,在失败时返回FALSE。
将CURLOPT_RETURNTRANSFER
设置为false,或者在收到结果后存储并打印结果。