60秒读懂世界API接口源码
<?php
/**
* Plugin Name: 60秒读懂世界
* Author: 大米api
* Author URL: https://api.qqsuu.cn/
*/
function callAPI($url, $params) {
$queryString = http_build_query(array_filter($params));
$requestURL = $url . '?' . $queryString;
$options = array(
'http' => array(
'method' => 'GET',
'header' => 'Content-type: application/x-www-form-urlencoded',
'ignore_errors' => true
)
);
$context = stream_context_create($options);
$response = file_get_contents($requestURL, false, $context);
if ($response === false) {
// 请求失败
echo "请求失败";
} else {
// 请求成功,输出响应内容
if($params['type']=='json'){
echo $response;
}else{
header("Content-Type:image/png");
echo $response;
}
}
}
$url = 'https://api.qqsuu.cn/api/dm-60s?apiKey=bVd6b080ejhaMEpabG0yMmJCaWNYZz09';
$type = isset($_GET['type']) ? $_GET['type'] : '';
$params = array(
'type' => $type
);
callAPI($url, $params);
保存为.PHP访问即可使用,输出 ?type=json
|| 版权声明
作者:大米
链接:https://blog.qqsuu.cn/7143.html
声明:如无特别声明本文即为原创文章仅代表个人观点,版权归《大米博客》所有,欢迎转载,转载请保留原文链接。
作者:大米
链接:https://blog.qqsuu.cn/7143.html
声明:如无特别声明本文即为原创文章仅代表个人观点,版权归《大米博客》所有,欢迎转载,转载请保留原文链接。
THE END
0
二维码
打赏
海报

60秒读懂世界API接口源码
<?php
/**
* Plugin Name: 60秒读懂世界
* Author: 大米api
* Author URL: https://api.qqsuu.cn/
*/
function callAPI($url, $params) {
$……

共有 0 条评论