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

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -