Tag Archives: sample api php

Sample Rest aPi call in php using curl

$service_url = ‘http://mydoubts.com’; $inputdata='<?xml version=”1.0″ encoding=”utf-8″?> <username>mydoubts</username> <domain>mydoubts.in</domain> <email>contact@mydoubts.in</email>’; curl_setopt($curl, CURLOPT_HTTPHEADER, array(“Content-Type: application/xml”)); curl_setopt($curl, CURLOPT_POST, true); // Do a regular HTTP POST curl_setopt($curl, CURLOPT_POSTFIELDS, $inputdata); // Set POST data curl_setopt($curl, CURLOPT_URL, $service_url); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_HEADER, 1); // return HTTP headers with response curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $response = curl_exec($curl);