<?php
require_once 'curl.func.php';
$appkey = 'your_appkey_here';//你的appkey
$channel='头条';//utf8 新闻频道(头条,财经,体育,娱乐,军事,教育,科技,NBA,股票,星座,女性,健康,育儿)
$url = "https://api.binstd.com/news/get?channel=$channel&appkey=$appkey";
$result = curlOpen($url, ['ssl'=>true]);
$jsonarr = json_decode($result, true);
if($jsonarr['status'] != 0)
{
echo $jsonarr['msg'];
exit();
}
$result = $jsonarr['result'];
echo $result['channel'].' '.$result['num']. '
';
foreach($result['list'] as $val)
{
echo $val['title'].' '.$val['time'].' '.$val['src'].' '.$val['category'].' '.$val['pic'].' '.$val['content'].' '.$val['url'].' '.$val['weburl'] . '
';
}
#!/usr/bin/python
# encoding:utf-8
import urllib2, json, urllib
# 1、获取新闻
data = {}
data["appkey"] = ",your_appkey_here"
data["channel"] = "头条" #新闻频道(头条,财经,体育,娱乐,军事,教育,科技,NBA,股票,星座,女性,健康,育儿)
url_values = urllib.urlencode(data)
url = "https://api.binstd.com/news/get" + "?" + url_values
request = urllib2.Request(url)
result = urllib2.urlopen(request)
jsonarr = json.loads(result.read())
if jsonarr["status"] != u"0":
print jsonarr["msg"]
exit()
result = jsonarr["result"]
print result["channel"],result["num"]
for val in result["list"]:
print val["title"],val["time"],val["src"],val["category"],val["pic"],val["content"],val["url"],val["weburl"]
package api.binstd.news;
import java.net.URLEncoder;
import api.util.HttpUtil;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
public class Get {
public static final String APPKEY = "your_appkey_here";// 你的appkey
public static final String URL = "https://api.binstd.com/news/get";
public static final String channel = "头条";// utf8 新闻频道(头条,财经,体育,娱乐,军事,教育,科技,NBA,股票,星座,女性,健康,育儿)
public static final int num = 10;// 数量 默认10,最大40
public static void NewGet() throws Exception {
String result = null;
String url = URL + "?channel=" + URLEncoder.encode(channel, "utf-8") + "&num=" + num + "&appkey=" + APPKEY;
try {
result = HttpUtil.sendGet(url, "utf-8");
JSONObject json = JSONObject.fromObject(result);
if (json.getInt("status") != 0) {
System.out.println(json.getString("msg"));
} else {
JSONObject resultarr = (JSONObject) json.opt("result");
String channel = resultarr.getString("channel");
String num = resultarr.getString("num");
System.out.println(channel + " " + num);
JSONArray list = resultarr.optJSONArray("list");
for (int i = 0; i < list.size(); i++) {
JSONObject obj = (JSONObject) list.opt(i);
String title = obj.getString("title");
String time = obj.getString("time");
String src = obj.getString("src");
String category = obj.getString("category");
String pic = obj.getString("pic");
String content = obj.getString("content");
String url1 = obj.getString("url");
String weburl = obj.getString("weburl");
System.out.println(title + " " + time + " " + src + " " + category + " " + pic + " " + content + " "
+ url1 + " " + weburl);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}