Monday, January 7, 2013

send request and get response using php json and curl client and server page

stp-1 create you client page which can send the request to server page
like sendclientrequest.php and paste below code

$url = "";
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, 'xmlstr='.$xmlStr);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$data = curl_exec($ch);
foreach($row as $fields){
echo $fields;
---------------receive request and send response using JSON AND CLIENT curl-----------------------
create ReceiveRequestReturnResponse.php get request and return respose in json curl
echo json_encode($row);

No comments:

Post a Comment