Page 1 of 1

executing problem

Posted: Thu Jan 15, 2009 6:00 am
by susrisha
Hi all,

Here is my problem:
There is an online api created by some site

Code: Select all

http://www.xyz.com/api.php?acct=[account]&a=[somthing]&b=[somethingelse]
Now i want to write a php in my local machine

Code: Select all

http://localhost/myapi.php?acct=[account]&a=[something]&b=[somethingelse]
so that once i access myapi.php with the given information, it will execute the code with xyz.com/api.php and present me with all the data that the api has responded.

Its like i simply want to execute the api.php from my localmachine. How do i do this?

Re: executing problem

Posted: Thu Jan 15, 2009 8:33 am
by susrisha
Thanks for no replies.. Think that was a dumb question. cURL will do my job.

Code: Select all

 
$URL='http://myurl/myapi.php?x=[something]&y=[somethingelse];
 
 
 
 
//initiate the curl 
$ch = curl_init();
//set the URL to the curl handle
curl_setopt($ch, CURLOPT_URL, $URL);
//ignore header
curl_setopt($ch, CURLOPT_HEADER, false);
 
 
// grab URL and pass it to the browser
curl_exec($ch);
 
// close CURL resource, and free up system resources
 
curl_close($ch);