require_once("curl.func.php");
$method = "POST";
$url = "http://open.liupai.net/weixinarticle/get";
$headers = NULL;
$params = array(
"appkey" => "yourappsecret",
"channelid" => "1",
"start" => "0",
"num" => "10"
);
$result = api_curl($method, $url, $headers, $params);
if ($result) {
$body = json_decode($result["body"], TRUE);
$status_code = $body["status"];
if ($status_code == "200") {
var_dump($body["result"]);
}else
var_dump($body);
}else
echo "发送请求失败";
/**
* 主函数
* @param args
*/
public static void main(String args[])
{
//请求地址设置
String url = "http://open.liupai.net/weixinarticle/get";
//请求方法设置
String requestMethod = "POST";
//请求头部设置
Map<String, String> headers = new HashMap<String, String>();
//请求参数设置
Map<String, String> params = new HashMap<String, String>();
params.put("appkey", "yourappsecret");
params.put("channelid", "1");
params.put("start", "0");
params.put("num", "10");
String result = proxyToDesURL(requestMethod, url, headers, params);
if (result != null) {
JSONObject jsonObject = JSONObject.parseObject(result);
String status_code = jsonObject.getString("status");
if (status_code.equals("200")) {
System.out.println("请求成功:" + jsonObject.getString("result"));
} else {
System.out.println("请求失败:" + jsonObject.getString("msg"));
}
} else {
System.out.println("发送请求异常");
}
}
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# 测试环境: python2.7
# 安装requests依赖 => pip install requests/ easy_install requests
import requests
import json
import sys
reload(sys)
sys.setdefaultencoding("utf-8")
def api_send_request(method, url, params=None, headers=None):
'''
转发请求到目的主机
@param method str 请求方法
@param url str 请求地址
@param params dict 请求参数
@param headers dict 请求头
'''
method = str.upper(method)
if method == "POST":
return requests.post(url=url, data=params, headers=headers)
elif method == "GET":
return requests.get(url=url, params=params, headers=headers)
else:
return None
method = "POST"
url = "http://open.liupai.net/weixinarticle/get"
headers = None
params = {
"appkey" : "yourappsecret",
"channelid" : "1",
"start" : "0",
"num" : "10"
}
result = api_send_request(method=method, url=url, params=params, headers=headers)
if result:
body = result.result
response = json.loads(body)
status_code = response["status"]
if (status_code
{
"status": 200,
"msg": "OK",
"result": {
"channel": "热门",
"channelid": 1,
"total": 36268,
"num": 1,
"start": 0,
"list": [
{
"title": "万众期盼",
"time": "2019-09-29",
"weixinname": "央视网",
"weixinaccount": "cctvcomweixin",
"weixinsummary": "央视网是中国网络电视台旗下互联网站业务,也是中央重点新闻网站,以视频为特色,以互动和移动服务为基础,以特色产品和独家观点为核心,面向全球、多终端、立体化的新闻信息共享平台。",
"weixinopenid": "gh_69a5cc78a6f7",
"channelid": 1,
"pic": "http://open.liupai.net/weixinarticle/upload/201909/29161001_77375.jpeg",
"content": "新中国成立70周年中央广播电视总台节目精彩纷呈你,准备好了吗?9月29日清晨6点至10月2日凌晨4点中央广播电视总台央视新闻精心推出70小时新媒体直播
《日出东方》这里有90多个机位30多个特殊视角无人值守机位1600多个镜头带你全方位看阅兵赏中国军人的飒爽英姿这里有70多路记者独家探营揭秘阅兵背后的苦与乐还有总台拉片会总台下午茶盛典朋友圈……你想看的内容这里都有!▽▽▽从东方既白,到华灯璀璨70个小时不间断,喜迎70华诞!从雄鹰呼啸,到英姿伟岸VR直播、Al剪辑呈现大国风范!从广场欢歌,到烟花绚烂有情有料,展现人民群众成千上万!总之一定要看,绝对震撼!点击视频,有彩蛋!▽▽▽三个日出日落之间无论你何时向"我"回眸精彩都会在你眼前转存70小时不间断只等你来看我们准备好了!编辑:单镜宇
责任编辑:孟夏来源:央视新闻、人民日报百岁老兵向祖国敬礼!我们要向他们敬礼!除了国庆,这个“十一”假期还要关心这些事!这一年,你可能弄丢了45件东西",
"url": "https://mp.weixin.qq.com/s?src=3×tamp=1488442388&ver=1",
"readnum": "100001",
"likenum": "2605"
}
]
}
}