8wDlpd.png
8wDFp9.png
8wDEOx.png
8wDMfH.png
8wDKte.png
搞笑段子 API
admin 2020-8-14

基本说明

接口地址:https://api.apiopen.top/getJoke
返回格式:json
请求方式:get/post
请求示例:https://api.apiopen.top/getJoke?page=1&count=2&type=video

请求参数说明

名称 类型 必填 说明
type String 必填 指定查询类型,可选参数(all/video/image/gif/text)
page String 选填 页码(传0或者不传会随机推荐)
count String 选填 每页返回数量

返回参数说明

名称 类型 说明
code int 状态码
message string 提示消息
result array 结果集合

JSON返回示例

{
code: 200,
message: "成功!",
result: [
{
sid: "31538081",
text: "从头到脚都精致的女神,娶回家舍得让她做家务吗?",
type: "video",
thumbnail: "http://wimg.spriteapp.cn/picture/2020/0729/5f20d97a78be5_wpd.jpg",
video: "http://uvideo.spriteapp.cn/video/2020/0729/5f20d97a78be5_wpd.mp4",
images: null,
up: "108",
down: "14",
forward: "0",
comment: "41",
uid: "23129497",
name: "你的意义",
header: "http://wimg.spriteapp.cn/profile/large/2019/07/04/5d1d74f678a8d_mini.jpg",
top_comments_content: "都给你们惯的",
top_comments_voiceuri: "",
top_comments_uid: "5653794",
top_comments_name: "宅小优",
top_comments_header: "http://wimg.spriteapp.cn/profile/large/2018/04/27/5ae339e226c00_mini.jpg",
passtime: "2020-08-06 19:59:07"
},
{
sid: "31519270",
text: "异地恋见面。。。",
type: "video",
thumbnail: "http://wimg.spriteapp.cn/picture/2020/0727/5f1e3e4476f5c_wpd.jpg",
video: "http://uvideo.spriteapp.cn/video/2020/0727/5f1e3e4476f5c_wpd.mp4",
images: null,
up: "188",
down: "7",
forward: "2",
comment: "39",
uid: "23126132",
name: "繁繁",
header: "http://wimg.spriteapp.cn/profile/large/2019/07/04/5d1d6ae649982_mini.jpg",
top_comments_content: "不着痕迹的先让你闻闻",
top_comments_voiceuri: "",
top_comments_uid: "20438036",
top_comments_name: "悲fsE",
top_comments_header: "http://wx.qlogo.cn/mmopen/NsXicLUicickpel973x87uu1K1yvImsHaJqUrmaqzWjUU4s2M7JxUkQowKQ9p0jnoRMc2p2VuwXp1OkeSmRTPQiarmM9zibEAx2NY/0",
passtime: "2020-08-06 19:29:05"
}
]
}

请求示例

<?php
/**
 * Created by PhpStorm.
 * User: FZS
 * Time: 2019/3/15 17:50
 */
//----------------------------------
// peakchao 调用类
//----------------------------------
class freeApi{
    private $apiUrl = 'https://api.apiopen.top/getJoke?page=1&count=1&type=video';
    /**
     * 获取  结果
     * @return array
     */
    public function getResult(){
        return $this->freeApiCurl($this->apiUrl);
    }
    /**
     * 请求接口返回内容
     * @param  string $url [请求的URL地址]
     * @param  string $params [请求的参数]
     * @param  int $ipost [是否采用POST形式]
     * @return  string
     */
    public function freeApiCurl($url,$params=false,$ispost=0){
        $ch = curl_init();
        curl_setopt( $ch, CURLOPT_HTTP_VERSION , CURL_HTTP_VERSION_1_1 );
        curl_setopt( $ch, CURLOPT_HTTP_VERSION , CURL_HTTP_VERSION_1_1 );
        curl_setopt( $ch, CURLOPT_USERAGENT , 'free-api' );
        curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT , 60 );
        curl_setopt( $ch, CURLOPT_TIMEOUT , 60);
        curl_setopt( $ch, CURLOPT_RETURNTRANSFER , true );
        if( $ispost )
        {
            curl_setopt( $ch , CURLOPT_POST , true );
            curl_setopt( $ch , CURLOPT_POSTFIELDS , $params );
            curl_setopt( $ch , CURLOPT_URL , $url );
        }
        else
        {
            if($params){
                curl_setopt( $ch , CURLOPT_URL , $url.'?'.$params );
            }else{
                curl_setopt( $ch , CURLOPT_URL , $url);
            }
        }
        $response = curl_exec( $ch );
        if ($response === FALSE) {
            return false;
        }
        curl_close( $ch );
        return $response;
    }
}
$res = new freeApi();
var_dump($res->getResult());

最新回复 (1)
    • 朕弟分享 | 专注小众,乐于分享!
      3
          
返回
发新帖 搜索 反馈 回顶部