php curl equivalent of post with content -
i have following get_file_contents code
$opts = array('http' => array( 'method' => 'post', 'header' => 'content-type: application/vnd+cbnv+endpoint', 'content' => $encryptedstring )); $buff = @file_get_contents($url, false, stream_context_create($opts));
how can done using curl ?
i trying
$handle = curl_init(); curl_setopt($handle, curlopt_url, $url); curl_setopt($handle, curlopt_returntransfer, true); curl_setopt($handle, curlopt_post, true); curl_setopt($handle, curlopt_postfields, $encryptedstring); $ret = curl_exec($handle); curl_close($handle);
$ret null , should string echo in @$url file
thank you
probably, have problem becouse foget add context header.
try code:
$handle = curl_init(); curl_setopt($handle, curlopt_url, $url); curl_setopt($handle, curlopt_returntransfer, true); curl_setopt($handle, curlopt_post, true); curl_setopt($handle, curlopt_postfields, $encryptedstring); curl_setopt($handle, curlopt_httpheader, ['content-type: application/vnd+cbnv+endpoint']); $ret = curl_exec($handle); curl_close($handle);
Comments
Post a Comment