-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