1 Star 0 Fork 0

siYuanJun/web-library

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
阿里云市场接口调用.php 1.53 KB
一键复制 编辑 原始数据 按行查看 历史
siYuanJun 提交于 2020-06-23 13:32 . Create 阿里云市场接口调用.php
function json($strjson)
{
exit(json_encode($strjson));
}
function jsonecho($status, $msg = '', $code = '', $url = '', $calback = '')
{
$msg = array(
"status" => $status,
"msg" => $msg,
"code" => $code,
"callback" => $calback,
"url" => $url
);
json($msg);
}
function curlGet($url, $headers = [])
{
$ch = curl_init();
$headers[] = 'Accept-Charset:utf-8';
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
// ip地址獲取
function ipAddrGet($number = 0)
{
$url = "https://jisuip.market.alicloudapi.com/ip/location";
$data = [
'ip' => getip(),
];
$data = http_build_query($data);
$url .= "?{$data}";
$appcode = "";
$headers = array();
array_push($headers, "Authorization:APPCODE " . $appcode);
try {
$result = curlGet($url, $headers);
$result = json_decode($result);
if($result) {
if($result->status == "01") {
return $result;
} else {
jsonecho($result->status, $result->msg);
}
} else {
jsonecho("error", "请求失败!");
}
} catch (Exception $exception) {
jsonecho("error", $exception);
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/siYuanJun/web-library.git
git@gitee.com:siYuanJun/web-library.git
siYuanJun
web-library
web-library
master

搜索帮助