1

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);
?>
1
  • 1
    When I run the exact request all I get is "<!--END Change for CF Stability Ticket 4235--> ". Also, you have a space before https: Commented Apr 9, 2014 at 19:16

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.