采集新闻
https://www.showapi.com/api/lookpoint/1071//md5签名方式--非简单签名
$showapi_appid
//添加其他参数
);
//创建参数(包括签名的处理)
function createparam ($paramarr,$showapi_secret) {
$parastr = ;
$signstr = ;
ksort($paramarr);
foreach ($paramarr as $key => $val) {
if ($key != '' && $val != '') {
$signstr .= $key.$val;
$parastr .= $key.'='.urlencode($val).'&';
}
}
$signstr .= $showapi_secret;//排好序的参数加上secret,进行md5
$sign = strtolower(md5($signstr));
$parastr .= 'showapi_sign='.$sign;//将md5后的值作为参数,便于服务器的效验
echo 排好序的参数:.$signstr.
\r\n;
return $parastr;
}
$param = createparam($paramarr,$showapi_secret);
$url = 'http://route.showapi.com/1071-1?'.$param;
echo 请求的url:.$url.
\r\n;
$result = file_get_contents($url);
echo 返回的json数据:
\r\n;
print $result.'
\r\n';
$result = json_decode($result);
echo
\r\n取出showapi_res_code的值:
\r\n;
print_r($result->showapi_res_code);
echo
\r\n;
?>