Tuesday 15 March 2011

How to use a PHP API -


There is a really simple API on this, and I was thinking that anyone could help me to use it . You can read more about the API, but this is a call, which gives returns. I'm trying to create a PHP page that calls when loaded, and prints the response. Any thoughts should start with me because I'm only starting to learn PHP,

you do this In this way, enter the input box and a form

  & lt; Form action = "your_script.php" method = "POST" & gt; & Lt; Input type = "edit" name = "address" /> & Lt; Input type = "submit" value = "go" /> & Lt; / Form & gt;   

If you use PHP to get the URL from the API

  if (isset ($ _ POST ['address'])) {$ ch = Curl_init (); Curl_setopt ($ c, CURLOPT_URL, 'http://mee.la/api.php?url='. Urlencode ($ _ POST ['address'])); Curl_setopt ($ CH, CURLOPT_RETURNTRANSFER, 1); $ Data = curl_xac ($ ch); }   

Then you can print the URL or use the header to redirect to that new url

  header ('location:' $. Data);    

No comments:

Post a Comment