首页 技术 正文
技术 2022年11月15日
0 收藏 726 点赞 5,085 浏览 1028 个字

https://www.showapi.com/api/view/1728

//md5签名方式--非简单签名
<?php
header("Content-Type:text/html;charset=UTF-8");
date_default_timezone_set("PRC");
$showapi_appid = 'xxxxxx'; //替换此值,在官网的"我的应用"中找到相关值
$showapi_secret = 'xxxxxxxxx'; //替换此值,在官网的"我的应用"中找到相关值
$paramArr = array(
'showapi_appid'=> $showapi_appid,
'url'=> "http://www.baidu.com"
//添加其他参数
);//创建参数(包括签名的处理)
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/1728-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";
?>

  

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,991
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,505
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,349
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,134
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,766
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,844