REST in PHP
REST is a framework for web services in php.
To use REST in php we use the CURL library.
CURL allows you to connect and communicate to many different types of servers with many different types of protocols.
It support http, https, ftp, telnet, gopher protocols.
CURL use the XML to transfer the data between client and server.
Using CURL you can use any method of http, like GET, POST, PUT, HEAD, and DELETE.
Using this you can load contents in your page from web server without reloading a page.
You can use it in inter domain URIs.
Here an Example to send GET request.
<?php
//url of server
$url = "http://www.example.com/index.php?id=1";
//initialization of curl variable.
$test = curl_init();
//setting particular option for GET method to variable.
curl_setopt($test,CURLOPT_URL,$url);
curl_setopt($test,CURLOPT_HTTPGET,true);
//executing variable and geting response.
$response = curl_exec($test);
//printing response.
echo $response;
?>
Change the code as per your requirement and enjoy.
by - Nanji Parmar
Good really n waiting 4 ur nxt post..
ReplyDeletewait and watch.
DeleteI don't have much knowledge on php, so it will really be helpful for a person like me, if you can add a little more description i.e. if you can go a little deeper to basics....
ReplyDelete