Home >Backend Development >PHP Tutorial >PHP curl 使用代码

PHP curl 使用代码

WBOY
WBOYOriginal
2016-06-20 12:59:08688browse

$ch=curl_init();
curl_setopt($ch,CURLOPT_URL,“http://dwz.cn/create.php”);
curl_setopt($ch,CURLOPT_POST,true);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
$data=array('url'=>'http://www.baidu.com/');
curl_setopt($ch,CURLOPT_POSTFIELDS,$data);
$strRes=curl_exec($ch);
curl_close($ch);
$arrResponse=json_decode($strRes,true);
var_dump($arrResponse);
if($arrResponse['status']!=0)
{
/*错误处理/
echo iconv('UTF-8','GBK',$arrResponse['err_msg']).“ok\n”;
}
/* tinyurl /
echo$arrResponse['tinyurl'].“\n”;

留着吧,
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn