sae获取 token
本帖最后由 lab 于 2016-7-20 10:25 编辑<?php
function curl_post($url,$data='',$timeout=30,$header=array()){
$arrCurlResult = array();
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);//ssl检测跳过
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS,$data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
curl_setopt ( $ch,CURLOPT_REFERER,"");
$output = curl_exec($ch);
$responseCode = curl_getinfo($ch,CURLINFO_HTTP_CODE);
$arrCurlResult['output'] = $output;//返回结果
$arrCurlResult['code'] = $responseCode;//返回http状态
curl_close($ch);
unset($ch);
return $arrCurlResult;
}
$header=array(
'Content-Type: application/json',
'X-Gizwits-Application-Id: 46a40ad548aa47398a335c5a97390fa8'//appid隐藏了
);
$params=array(
"phone_id"=> "apiary"
);
$params_query=json_encode($params);
echo $params_query;
$result=@curl_post('http://api.gizwits.com/app/users',$params_query,30,$header);
echo '<pre>';
print_r($result);
?>
> --header "X-Gizwits-Application-Id: {46a40ad548aa47398a335c5a97390fa8}" \
这里appid是不需要大括号的{} 本帖最后由 lab 于 2016-7-20 10:26 编辑
~~~~~~~~~~
页:
[1]