executing problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
susrisha
Forum Contributor
Posts: 439
Joined: Thu Aug 07, 2008 11:43 pm
Location: Hyderabad India

executing problem

Post 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?
User avatar
susrisha
Forum Contributor
Posts: 439
Joined: Thu Aug 07, 2008 11:43 pm
Location: Hyderabad India

Re: executing problem

Post 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);
 
Post Reply