-1
我該如何在PHP中使用curl來執行下面的代碼?我該如何使用curl來代替fopen
因爲fopen在服務器端存在問題。此示例代碼段是約wizIQ API的使用...
class HttpRequest
{
function wiziq_do_post_request($url, $data, $optional_headers = null)
{
$params = array('http' => array(
'method' => 'POST',
'content' => $data
));
if ($optional_headers !== null)
{
$params['http']['header'] = $optional_headers;
}
$ctx = stream_context_create($params);
$fp = fopen($url, 'r+',false, $ctx);
if (!$fp)
{
throw new Exception("Problem with $url, $php_errormsg");
}
$response = @stream_get_contents($fp);
if ($response === false)
{
throw new Exception("Problem reading data from $url, $php_errormsg");
}
return $response;
}
}//end class HttpRequest
其中發佈數據? – 2014-11-06 07:16:09
@RakeshSharma檢查 – 2014-11-06 07:19:17
Bravo CS GO。它運作良好! – Burhan 2014-11-06 07:56:21