php curl函数实例

 <?php

 function login(){
$url = 'http://jspatch.qq.com/offline/check?qver=6.2.0.427&hver=0&biz=2164&pf=2&uin=3323687546&osrelease=9.1&mask=0';
$data='{}';
$curl = curl_init (); //初始化句柄
curl_setopt ($curl, CURLOPT_URL,$url); //设置请求的url
curl_setopt ( $curl, CURLOPT_CUSTOMREQUEST, 'GET'); //设置请求方式
curl_setopt($curl, CURLOPT_PUT, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); //设为TRUE把curl_exec()结果转化为字串,而不是直接输出
curl_setopt ( $curl, CURLOPT_HEADER, 0 );
$header=array();
curl_setopt ( $curl, CURLOPT_HTTPHEADER, $header ); //设置http头信息
curl_setopt ( $curl, CURLOPT_POSTFIELDS, $data ); //设置提交的参数
$res = curl_exec ( $curl ); //执行
curl_close ( $curl ); //关闭
$result=json_decode($res,true);
print_r($res);
} login();

  

上一篇:Cortex-M系列微控制器学习资源汇总


下一篇:win8下ctrl+alt+down失效问题