全国新闻查询接口

每10分钟刷新。新闻API接口,包括多个频道的最新新闻,有国内焦点、国际焦点、军事焦点、财经焦点、互联网焦点、房产焦点、汽车焦点、体育焦点、娱乐焦点、游戏焦点等等。

使用期限

价格

9
用户评价: 暂无评价

购买人数:31

规格与周期

9.00元/10,000次”,“一年

联系电话

服务保障

精选优质服务商
7*8小时在线客服
专业测试保证品质
退款售后无忧
API文档

新闻查询接口

调用地址:https://service-o5ikp40z-1255468759.ap-shanghai.apigateway.myqcloud.com/release/news

请求方式:GET

返回类型:JSON

API调用: API调用说明(secret_id & secret_key)

去调试

请求参数(Headers)

名称
类型
是否必须
描述
暂无数据

请求参数(Qurey)

名称
类型
是否必须
描述
channelId
string
新闻频道id,必须精确匹配
channelName
string
新闻频道名称,可模糊匹配
needAllList
string
是否需要最全的返回资料。包括每一段文本和每一张图。用list的形式返回。
needContent
string
是否需要返回正文,1为需要,其他为不需要
page
string
页数,默认1。每页最多20条记录。
title
string
标题名称,可模糊匹配

请求参数(Body)

名称
类型
是否必须
描述
暂无数据

请求示例

import urllib2, ssl, datetime, hmac, base64, hashlib

host = 'service-o5ikp40z-1255468759.ap-shanghai.apigateway.myqcloud.com'
url = 'https://service-o5ikp40z-1255468759.ap-shanghai.apigateway.myqcloud.com/release'
path = '/news'
source = 'source'
method ='GET'
querys = "channelId=&channelName=&needAllList=&needContent=&page=1&title=";
GMT_FORMAT = '%a, %d %b %Y %H:%M:%S GMT'

#云市场分配的密钥Id
SecretId='xxx'
#云市场分配的密钥Key
SecretKey='xxx'
dateTime = datetime.datetime.utcnow().strftime(GMT_FORMAT)
auth = "hmac id=\"" + SecretId + "\", algorithm=\"hmac-sha1\", headers=\"date source\", signature=\""
signStr = "date: " + dateTime + "\n" + "source: " + source
sign = hmac.new(SecretKey, signStr, hashlib.sha1).digest()
sign = base64.b64encode(sign)
sign = auth + sign + "\""

url = url + path + '?' + querys
request = urllib2.Request(url)

request.add_header('Authorization', sign)
request.add_header('Host', host)
request.add_header('Source', 'source')
request.add_header('Date', dateTime)
request.add_header('X-Requested-With', 'XMLHttpRequest')
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
response = urllib2.urlopen(request, context=ctx)
content = response.read()
if (content):
    print(content)
curl -v -X GET https://service-o5ikp40z-1255468759.ap-shanghai.apigateway.myqcloud.com/release/news ?channelId=&channelName=&needAllList=&needContent=&page=1&title=-H 'Host:service-o5ikp40z-1255468759.ap-shanghai.apigateway.myqcloud.com' -H 'Source:source' -H 'Date:Mon, 19 Mar 2018 12:08:40 GMT' -H 'Authorization:hmac id = "AKIDi6qE41WgJ9w8h4h9zq68Vq24d1beIuN0qIwU", algorithm = "hmac-sha1", headers = "date source", signature = yMCxXNytW5nvVGNZ8aBtRxmiLJ4=' -H 'X-Requested-With:XMLHttpRequest' 
//请用云市场分配给您的密钥计算签名并放入请求头,Date为当前的GMT时间
<?php
$host = 'service-o5ikp40z-1255468759.ap-shanghai.apigateway.myqcloud.com';
$url = 'https://service-o5ikp40z-1255468759.ap-shanghai.apigateway.myqcloud.com/release';
$path = '/news';
$method = 'GET';
$source = 'source';

#云市场分配的密钥Id
$SecretId = 'xxx';
#云市场分配的密钥Key
$SecretKey = 'xxx';
$dateTime = gmdate('D, d M Y H:i:s T');
$auth = 'hmac id="' . $SecretId . '", algorithm="hmac-sha1", headers="date source", signature="';
$signStr = 'date: ' . $dateTime . "\n" . 'source: ' . $source;
$sign = base64_encode(hash_hmac('sha1', $signStr, $SecretKey, true));
$sign = $auth . $sign . '"';

$querys = "channelId=&channelName=&needAllList=&needContent=&page=1&title=";
$url = $url . $path . "?" . $querys;

$headers = array(
    "Host: $host",
    'Accept: text/html, */*; q=0.01',
    "Source: $source",
    "Date: $dateTime",
    "Authorization: $sign",
    'X-Requested-With: XMLHttpRequest',
    'Accept-Encoding: gzip, deflate, sdch'
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
$data = curl_exec($ch);
if (curl_errno($ch)) {
    echo "Error: " . curl_error($ch);
} else {
    // Show me the result
    var_dump($data);
    curl_close($ch);
}
using System.IO;
using System.Text;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System;

public class CsharpTest
{
    public static String HMACSHA1Text(String EncryptText, String EncryptKey)
    {
            HMACSHA1 hmacsha1 = new HMACSHA1();
            hmacsha1.Key = System.Text.Encoding.UTF8.GetBytes(EncryptKey);

            byte[] dataBuffer = System.Text.Encoding.UTF8.GetBytes(EncryptText);
            byte[] hashBytes = hmacsha1.ComputeHash(dataBuffer);
            return Convert.ToBase64String(hashBytes);
    }

    public static void Main(String[] args)
    {
        String url = "https://service-o5ikp40z-1255468759.ap-shanghai.apigateway.myqcloud.com/release";
        String host = "service-o5ikp40z-1255468759.ap-shanghai.apigateway.myqcloud.com";
        String path = "/news";
        String method = "GET";
        String querys = "channelId=&channelName=&needAllList=&needContent=&page=1&title=";
        String source = "source";

        //云市场分配的密钥Id
        String  secretId = "xxx";
        //云市场分配的密钥Key
        String  secretKey = "xxx";

        String dt = DateTime.UtcNow.GetDateTimeFormats('r')[0]; //Mon, 19 Mar 2018 12:00:44 GMT
        url = url + path + "?" + querys;

        String signStr = "x-date: " + dt + "\n" + "source: " + source;
        String sign = HMACSHA1Text(signStr, secretKey);

        String auth = "hmac id=\"" + secretId + "\", algorithm=\"hmac-sha1\", headers=\"x-date source\", signature=\"";
        auth = auth + sign + "\"";
        Console.WriteLine(auth + "\n");

        HttpWebRequest httpRequest = null;
        HttpWebResponse httpResponse = null;

        if (url.Contains("https://"))
        {
            ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
            httpRequest = (HttpWebRequest)WebRequest.CreateDefault(new Uri(url));
        }
        else
        {
            httpRequest = (HttpWebRequest)WebRequest.Create(url);
        }

        httpRequest.Method = method;
        httpRequest.Headers.Add("Authorization", auth);
        httpRequest.Headers.Add("Source", source);
        httpRequest.Headers.Add("X-date", dt);

        try
        {
            httpResponse = (HttpWebResponse)httpRequest.GetResponse();
        }
        catch (WebException ex)
        {
            httpResponse = (HttpWebResponse)ex.Response;
        }

        Console.WriteLine(httpResponse.StatusCode);
        Console.WriteLine(httpResponse.Headers);
        Stream st = httpResponse.GetResponseStream();
        StreamReader reader = new StreamReader(st, Encoding.GetEncoding("utf-8"));
        Console.WriteLine(reader.ReadToEnd());
        Console.WriteLine("\n");

    }

    public static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
    {
        return true;
    }
}
package main

import (
    "time"
    "fmt"
    "crypto/hmac"
    "crypto/sha1"
    "io"
    "io/ioutil"
    "encoding/base64"
    "net/http"
)


func calcAuthorization(source string, secretId string, secretKey string) (sign string, dateTime string, err error) {
    timeLocation, _ := time.LoadLocation("Etc/GMT")
    dateTime = time.Now().In(timeLocation).Format("Mon, 02 Jan 2006 15:04:05 GMT")
    sign = fmt.Sprintf("x-date: %s\nsource: %s", dateTime, source)
    fmt.Println(sign)

    //hmac-sha1
    h := hmac.New(sha1.New, []byte(secretKey))
    io.WriteString(h, sign)
    sign = fmt.Sprintf("%x", h.Sum(nil))
    sign = string(h.Sum(nil))
    fmt.Println("sign:", fmt.Sprintf("%s", h.Sum(nil)))

    //base64
    sign = base64.StdEncoding.EncodeToString([]byte(sign))
    fmt.Println("sign:", sign)

    auth := fmt.Sprintf("hmac id=\"%s\", algorithm=\"hmac-sha1\", headers=\"x-date source\", signature=\"%s\"",
        secretId, sign)
    fmt.Println("auth:", auth)

    return auth, dateTime, nil
}

func main () {

    //云市场分配的密钥Id
    SecretId := "xxx"
    //云市场分配的密钥Key
    SecretKey := "xxx"
    source := "source"

    sign, dateTime, err := calcAuthorization(source, SecretId, SecretKey)
    if err != nil {
        fmt.Println(err)
        return
    }

    defaultDomain := "service-o5ikp40z-1255468759.ap-shanghai.apigateway.myqcloud.com"
    path := "/news"
    query := "channelId=&channelName=&needAllList=&needContent=&page=1&title="
    url := "https://service-o5ikp40z-1255468759.ap-shanghai.apigateway.myqcloud.com/release"
    reqUrl := url + path + "?" + query
    client := &http.Client{
        Timeout: 7 * time.Second,//set timeout
    }

    req, err := http.NewRequest("GET", reqUrl, nil) //set body
    if err != nil {
        fmt.Println(err)
        return
    }

    req.Header.Set("Accept", "*/*")
    req.Header.Set("Accept-Charset", "utf-8;")
    req.Header.Set("Host", defaultDomain)
    req.Header.Set("Source", source)
    req.Header.Set("X-Date", dateTime)
    req.Header.Set("Authorization", sign)

    resp, err := client.Do(req)
    if err != nil {
        fmt.Println(err)
        return
    }
    defer resp.Body.Close()

    fmt.Println("status code:", resp.StatusCode)

    //get resp header
    var headerMsg string
    for key, _ := range resp.Header {
        headerMsg += fmt.Sprintf("\n%s:%s", key, resp.Header.Get(key))
    }
    fmt.Println(headerMsg)

    body, err := ioutil.ReadAll(resp.Body)
    if err != nil {
        fmt.Println(err)
        return
    }

    fmt.Println(string(body))
}
import java.io.*;
import java.io.UnsupportedEncodingException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.text.SimpleDateFormat;
import java.util.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.URL;
import java.net.URLConnection;
import java.net.HttpURLConnection;
import sun.misc.BASE64Encoder;

class test
{
    public static String sign(String secret, String timeStr)
        throws NoSuchAlgorithmException, UnsupportedEncodingException, InvalidKeyException {
        //get signStr
        String signStr = "date: " + timeStr + "\n" + "source: " + "source";
        //get sig
        String sig = null;
        Mac mac1 = Mac.getInstance("HmacSHA1");
        byte[] hash;
        SecretKeySpec secretKey = new SecretKeySpec(secret.getBytes("UTF-8"), mac1.getAlgorithm());
        mac1.init(secretKey);
        hash = mac1.doFinal(signStr.getBytes("UTF-8"));
        sig = new BASE64Encoder().encode(hash);
        System.out.println("signValue--->" + sig);
        return sig;
    }

    public static void main(String[] args) {
        String result = "";
        BufferedReader in = null;

        //get current GMT time
        Calendar cd = Calendar.getInstance();
        SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss 'GMT'", Locale.US);
        sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
        String timeStr = sdf.format(cd.getTime());

        String host = "service-o5ikp40z-1255468759.ap-shanghai.apigateway.myqcloud.com";
        String path = "/news";
        String query = "channelId=&channelName=&needAllList=&needContent=&page=1&title=";
        String url = "https://service-o5ikp40z-1255468759.ap-shanghai.apigateway.myqcloud.com/release";
        url = url + path + "?" + query;
        String source = "source";


        //云市场分配的密钥Id
        String secretId = "xxx";
        //云市场分配的密钥Key
        String secretKey = "xxx";

        try {
            String urlNameString = url;
            URL realUrl = new URL(urlNameString);
            // 打开和URL之间的连接
            URLConnection connection = realUrl.openConnection();
            HttpURLConnection httpUrlCon = (HttpURLConnection)connection;
            // 设置通用的请求属性
            httpUrlCon.setRequestProperty("Host", host);
            httpUrlCon.setRequestProperty("Accept", "text/html, */*; q=0.01");
            httpUrlCon.setRequestProperty("Source", source );
            httpUrlCon.setRequestProperty("Date", timeStr);
            String sig = sign(secretKey,timeStr);
            String authen = "hmac id=\"" + secretId + "\", algorithm=\"hmac-sha1\", headers=\"date source\", signature=\"" + sig + "\"";
            System.out.println("authen --->" + authen);
            httpUrlCon.setRequestProperty("Authorization", authen);
            httpUrlCon.setRequestProperty("X-Requested-With", "XMLHttpRequest");
            httpUrlCon.setRequestProperty("Accept-Encoding", "gzip, deflate, sdch");
            // 建立实际的连接
            httpUrlCon.connect();
            // 获取所有响应头字段
            Map<String, List<String>> map = httpUrlCon.getHeaderFields();
            // 遍历所有的响应头字段
            for (String key : map.keySet()) {
                System.out.println(key + "--->" + map.get(key));
            }
            // 定义 BufferedReader输入流来读取URL的响应
            in = new BufferedReader(new InputStreamReader(
            httpUrlCon.getInputStream()));
            String line;
            while ((line = in.readLine()) != null) {
                result += line;
            }

            System.out.println(result);

        } catch (Exception e) {
            System.out.println("发送GET请求出现异常!" + e);
            e.printStackTrace();
        }
        // 使用finally块来关闭输入流
        finally {
            try {
                if (in != null) {
                    in.close();
                }
            } catch (Exception e2) {
                e2.printStackTrace();
            }
        }
    }
}
/**
 * npm install crypto-js axios
 */
var CryptoJS = require("crypto-js");
var axios = require('axios');

var nowDate = new Date();
var dateTime = nowDate.toGMTString();

var host = "service-o5ikp40z-1255468759.ap-shanghai.apigateway.myqcloud.com";
var path = "/news";
var query = "channelId=&channelName=&needAllList=&needContent=&page=1&title=";
var url = "https://service-o5ikp40z-1255468759.ap-shanghai.apigateway.myqcloud.com/release";
url = url + path + "?" + query;
var source = "source";

//云市场分配的密钥Id
var secretId = "xxx";
//云市场分配的密钥Key
var secretKey = "xxx";

var auth = "hmac id=\"" + secretId + "\", algorithm=\"hmac-sha1\", headers=\"x-date source\", signature=\"";
var signStr = "x-date: " + dateTime + "\n" + "source: " + source;
var sign = CryptoJS.HmacSHA1(signStr, secretKey)
console.log(sign.toString())
sign = CryptoJS.enc.Base64.stringify(sign)
sign = auth + sign + "\""
console.log(sign)

var instance = axios.create({
    baseURL: url,
    timeout: 5000,
    headers: {
        "Source": source,
        "X-date": dateTime,
        "Authorization": sign
    },
    withCredentials: true
});


instance.get()
    .then(function (response) {
        console.log(response);
    })
    .catch(function (error) {
        console.log(error);
    });

正常返回示例

{
	"showapi_res_code": 0,
	"showapi_res_error": "",
	"showapi_res_body": {
		"ret_code": 0,
		"pagebean": {
			"allPages": 5,
			"contentlist": [
				{
					"allList": [
						"足球,有着“世界第一运动”的美誉,是全球体育界最具影响力的单项体育运动。就在几天前,一场足球盛宴——欧洲杯完美落幕,回首历时近一个月的赛程,足球所带来的热血与激情,伴随着球迷朋友们一起见证了一个个不眠之夜,其魅力自然可见一斑。",
						"而在漳州,也有一批热爱足球运动的青少年,这些小足球员们“小荷才露尖尖角”,他们挥洒汗水,正义无反顾地向着“足球梦”追逐奔跑。",
						"张梦丽与其他踢球的孩子一样,为了足球她也笑过、也哭过。学校里女子足球队成立的时候,是她最开心的时候,因为球队的创立代表着自己有展示自我风采的舞台,可以出去比赛了。后来因为年龄大了几个月,她没有办法进入省队,也没能去参加省里的比赛,这些都成了她的遗憾。",
						"一路走来,足球成了张梦丽最喜欢的东西。有时,她会梦到自己到省队了,或者去参加比赛了,这时她甚至会激动得醒来。学习成绩在班级排名中上的她表示,未来自己想考到好的学校,但同时不会放弃对足球的执着与热爱。"
					],
					"pubDate": "2016-07-14 11:36:05",
					"title": "漳州足球大数据:拥有足球特色学校91所国家级46所",
					"channelName": "社会最新",
					"imageurls": [],
					"desc": "就在几天前,一场足球盛宴——欧洲杯完美落幕,回首历时近一个月的赛程,足球所带来的热血与激情,伴随着球迷朋友们一起见证了一个个不眠之夜,其魅力自然可见一斑。在漳州,也有一批热爱足球运动的青少年,这些小足球员们“小荷才露尖尖角”,他们挥洒汗水,正义无反顾地向着“足球梦”追逐奔跑。",
					"source": "手机中国",
					"channelId": "5572a10bb3cdc86cf39001f8",
					"nid": "10427894029754912460",
					"link": "http://m.china.com.cn/baidu/doc_1_3_1596740.html"
				},
				{
					"allList": [
						"提起万达,很多人也许会自然联想到另一个词——并购,这仿佛已经成了王老板的主要生存法则。两天前,万达集团旗下的美国AMC院线宣布,以9.21亿英镑的价格并购欧洲第一大院线——Odeon & UCI院线,在“买买买”的路上又迈出震惊世界的一步。",
						"体育和影视可以说是万达文化产业的左膀右臂,万达影视的并购之路方兴未艾,而万达体育自成立之后更是大动作不断。以盈方体育传媒集团和世界铁人公司为基底的万达体育,到了2016年开始将重心转向经营,先是成为国际足联顶级赞助商,随后又成为国际篮联全球独家商业合作伙伴。插上这对翅膀的万达体育除了继续扩充自己的资源池以外,还开始向世界展示自己的品牌影响力。",
					],
					"pubDate": "2016-07-14 10:48:04",
					"title": "创立“中国杯” 习惯了“买买买”的万达要靠自创IP为中国足球出把力",
					"channelName": "国内最新",
					"imageurls": [],
					"desc": "“中国杯”则是万达与国际足联合作的第一项赛事落地,这也标志着万达开始着重加强自己的赛事运营业务。"
					"source": "禹唐体育",
					"sentiment_display": 0,
					"channelId": "5572a109b3cdc86cf39001db",
					"nid": "2623216982465905421",
					"link": "http://ytsports.cn/news-10662.html?cid=64"
				},
				{
					"allList": [
						{
							"height": 426,
							"width": 640,
							"url": "http://img1.gtimg.com/sports/pics/hv1/198/144/2098/136459368.jpg"
						},
						"《体育产业发展“十三五”规划》指出,积极研究推进发行以中国足球职业联赛为竞猜对象的",
						"腾讯体育7月14日讯 13日,国家体育总局在其官网刊登了《体育产业发展“十三五”规划》,其中明确指出,加强三大球联赛建设、积极研究推进积极研究推进发行以中国足球职业联赛为竞猜对象的足球"
					],
					"pubDate": "2016-07-14 10:17:26",
					"title": "体育产业"十三五"规划:推进中国足球联赛竞彩",
					"channelName": "国内足球最新",
					"imageurls": [
						{
							"height": 426,
							"width": 640,
							"url": "http://img1.gtimg.com/sports/pics/hv1/198/144/2098/136459368.jpg"
						}
					],
					"desc": "《体育产业发展“十三五”规划》指出,积极研究推进发行以中国足球职业联赛为竞猜对象的足球彩票腾讯体育7月14日讯13日,国家体育总局在其官网刊登了《体育产业发展“十三五”规划》,其中明确指出,加强三大球联赛建设、积极研究推进积极研究推进发行以中国足球职业联赛为竞猜对象的足球彩票。《体育产业发展“十三五”规",
					"source": "国内足球新闻",
					"channelId": "5572a10ab3cdc86cf39001e8",
					"link": "http://sports.qq.com/a/20160714/021723.htm"
				}
			],
			"currentPage": 1,
			"allNum": 94,
			"maxResult": 20
		}
	}
}

失败返回示例

{
  "showapi_res_code": -1,
  "showapi_res_error": "失败信息",
  "showapi_res_body": {}
}

返回码定义

返回码
返回信息
描述
无参数

新闻频道查询

调用地址:https://service-o5ikp40z-1255468759.ap-shanghai.apigateway.myqcloud.com/release/channel

请求方式:GET

返回类型:JSON

API调用: API调用说明(secret_id & secret_key)

去调试

请求参数(Headers)

名称
类型
是否必须
描述
暂无数据

请求参数(Qurey)

名称
类型
是否必须
描述
暂无数据

请求参数(Body)

名称
类型
是否必须
描述
暂无数据

请求示例

import urllib2, ssl, datetime, hmac, base64, hashlib

host = 'service-o5ikp40z-1255468759.ap-shanghai.apigateway.myqcloud.com'
url = 'https://service-o5ikp40z-1255468759.ap-shanghai.apigateway.myqcloud.com/release'
path = '/channel'
source = 'source'
method ='GET'
querys = "";
GMT_FORMAT = '%a, %d %b %Y %H:%M:%S GMT'

#云市场分配的密钥Id
SecretId='xxx'
#云市场分配的密钥Key
SecretKey='xxx'
dateTime = datetime.datetime.utcnow().strftime(GMT_FORMAT)
auth = "hmac id=\"" + SecretId + "\", algorithm=\"hmac-sha1\", headers=\"date source\", signature=\""
signStr = "date: " + dateTime + "\n" + "source: " + source
sign = hmac.new(SecretKey, signStr, hashlib.sha1).digest()
sign = base64.b64encode(sign)
sign = auth + sign + "\""

url = url + path + '?' + querys
request = urllib2.Request(url)

request.add_header('Authorization', sign)
request.add_header('Host', host)
request.add_header('Source', 'source')
request.add_header('Date', dateTime)
request.add_header('X-Requested-With', 'XMLHttpRequest')
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
response = urllib2.urlopen(request, context=ctx)
content = response.read()
if (content):
    print(content)
curl -v -X GET https://service-o5ikp40z-1255468759.ap-shanghai.apigateway.myqcloud.com/release/channel -H 'Host:service-o5ikp40z-1255468759.ap-shanghai.apigateway.myqcloud.com' -H 'Source:source' -H 'Date:Mon, 19 Mar 2018 12:08:40 GMT' -H 'Authorization:hmac id = "AKIDi6qE41WgJ9w8h4h9zq68Vq24d1beIuN0qIwU", algorithm = "hmac-sha1", headers = "date source", signature = yMCxXNytW5nvVGNZ8aBtRxmiLJ4=' -H 'X-Requested-With:XMLHttpRequest' 
//请用云市场分配给您的密钥计算签名并放入请求头,Date为当前的GMT时间
<?php
$host = 'service-o5ikp40z-1255468759.ap-shanghai.apigateway.myqcloud.com';
$url = 'https://service-o5ikp40z-1255468759.ap-shanghai.apigateway.myqcloud.com/release';
$path = '/channel';
$method = 'GET';
$source = 'source';

#云市场分配的密钥Id
$SecretId = 'xxx';
#云市场分配的密钥Key
$SecretKey = 'xxx';
$dateTime = gmdate('D, d M Y H:i:s T');
$auth = 'hmac id="' . $SecretId . '", algorithm="hmac-sha1", headers="date source", signature="';
$signStr = 'date: ' . $dateTime . "\n" . 'source: ' . $source;
$sign = base64_encode(hash_hmac('sha1', $signStr, $SecretKey, true));
$sign = $auth . $sign . '"';

$querys = "";
$url = $url . $path . "?" . $querys;

$headers = array(
    "Host: $host",
    'Accept: text/html, */*; q=0.01',
    "Source: $source",
    "Date: $dateTime",
    "Authorization: $sign",
    'X-Requested-With: XMLHttpRequest',
    'Accept-Encoding: gzip, deflate, sdch'
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
$data = curl_exec($ch);
if (curl_errno($ch)) {
    echo "Error: " . curl_error($ch);
} else {
    // Show me the result
    var_dump($data);
    curl_close($ch);
}
using System.IO;
using System.Text;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System;

public class CsharpTest
{
    public static String HMACSHA1Text(String EncryptText, String EncryptKey)
    {
            HMACSHA1 hmacsha1 = new HMACSHA1();
            hmacsha1.Key = System.Text.Encoding.UTF8.GetBytes(EncryptKey);

            byte[] dataBuffer = System.Text.Encoding.UTF8.GetBytes(EncryptText);
            byte[] hashBytes = hmacsha1.ComputeHash(dataBuffer);
            return Convert.ToBase64String(hashBytes);
    }

    public static void Main(String[] args)
    {
        String url = "https://service-o5ikp40z-1255468759.ap-shanghai.apigateway.myqcloud.com/release";
        String host = "service-o5ikp40z-1255468759.ap-shanghai.apigateway.myqcloud.com";
        String path = "/channel";
        String method = "GET";
        String querys = "";
        String source = "source";

        //云市场分配的密钥Id
        String  secretId = "xxx";
        //云市场分配的密钥Key
        String  secretKey = "xxx";

        String dt = DateTime.UtcNow.GetDateTimeFormats('r')[0]; //Mon, 19 Mar 2018 12:00:44 GMT
        url = url + path + "?" + querys;

        String signStr = "x-date: " + dt + "\n" + "source: " + source;
        String sign = HMACSHA1Text(signStr, secretKey);

        String auth = "hmac id=\"" + secretId + "\", algorithm=\"hmac-sha1\", headers=\"x-date source\", signature=\"";
        auth = auth + sign + "\"";
        Console.WriteLine(auth + "\n");

        HttpWebRequest httpRequest = null;
        HttpWebResponse httpResponse = null;

        if (url.Contains("https://"))
        {
            ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
            httpRequest = (HttpWebRequest)WebRequest.CreateDefault(new Uri(url));
        }
        else
        {
            httpRequest = (HttpWebRequest)WebRequest.Create(url);
        }

        httpRequest.Method = method;
        httpRequest.Headers.Add("Authorization", auth);
        httpRequest.Headers.Add("Source", source);
        httpRequest.Headers.Add("X-date", dt);

        try
        {
            httpResponse = (HttpWebResponse)httpRequest.GetResponse();
        }
        catch (WebException ex)
        {
            httpResponse = (HttpWebResponse)ex.Response;
        }

        Console.WriteLine(httpResponse.StatusCode);
        Console.WriteLine(httpResponse.Headers);
        Stream st = httpResponse.GetResponseStream();
        StreamReader reader = new StreamReader(st, Encoding.GetEncoding("utf-8"));
        Console.WriteLine(reader.ReadToEnd());
        Console.WriteLine("\n");

    }

    public static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
    {
        return true;
    }
}
package main

import (
    "time"
    "fmt"
    "crypto/hmac"
    "crypto/sha1"
    "io"
    "io/ioutil"
    "encoding/base64"
    "net/http"
)


func calcAuthorization(source string, secretId string, secretKey string) (sign string, dateTime string, err error) {
    timeLocation, _ := time.LoadLocation("Etc/GMT")
    dateTime = time.Now().In(timeLocation).Format("Mon, 02 Jan 2006 15:04:05 GMT")
    sign = fmt.Sprintf("x-date: %s\nsource: %s", dateTime, source)
    fmt.Println(sign)

    //hmac-sha1
    h := hmac.New(sha1.New, []byte(secretKey))
    io.WriteString(h, sign)
    sign = fmt.Sprintf("%x", h.Sum(nil))
    sign = string(h.Sum(nil))
    fmt.Println("sign:", fmt.Sprintf("%s", h.Sum(nil)))

    //base64
    sign = base64.StdEncoding.EncodeToString([]byte(sign))
    fmt.Println("sign:", sign)

    auth := fmt.Sprintf("hmac id=\"%s\", algorithm=\"hmac-sha1\", headers=\"x-date source\", signature=\"%s\"",
        secretId, sign)
    fmt.Println("auth:", auth)

    return auth, dateTime, nil
}

func main () {

    //云市场分配的密钥Id
    SecretId := "xxx"
    //云市场分配的密钥Key
    SecretKey := "xxx"
    source := "source"

    sign, dateTime, err := calcAuthorization(source, SecretId, SecretKey)
    if err != nil {
        fmt.Println(err)
        return
    }

    defaultDomain := "service-o5ikp40z-1255468759.ap-shanghai.apigateway.myqcloud.com"
    path := "/channel"
    query := ""
    url := "https://service-o5ikp40z-1255468759.ap-shanghai.apigateway.myqcloud.com/release"
    reqUrl := url + path + "?" + query
    client := &http.Client{
        Timeout: 7 * time.Second,//set timeout
    }

    req, err := http.NewRequest("GET", reqUrl, nil) //set body
    if err != nil {
        fmt.Println(err)
        return
    }

    req.Header.Set("Accept", "*/*")
    req.Header.Set("Accept-Charset", "utf-8;")
    req.Header.Set("Host", defaultDomain)
    req.Header.Set("Source", source)
    req.Header.Set("X-Date", dateTime)
    req.Header.Set("Authorization", sign)

    resp, err := client.Do(req)
    if err != nil {
        fmt.Println(err)
        return
    }
    defer resp.Body.Close()

    fmt.Println("status code:", resp.StatusCode)

    //get resp header
    var headerMsg string
    for key, _ := range resp.Header {
        headerMsg += fmt.Sprintf("\n%s:%s", key, resp.Header.Get(key))
    }
    fmt.Println(headerMsg)

    body, err := ioutil.ReadAll(resp.Body)
    if err != nil {
        fmt.Println(err)
        return
    }

    fmt.Println(string(body))
}
import java.io.*;
import java.io.UnsupportedEncodingException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.text.SimpleDateFormat;
import java.util.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.URL;
import java.net.URLConnection;
import java.net.HttpURLConnection;
import sun.misc.BASE64Encoder;

class test
{
    public static String sign(String secret, String timeStr)
        throws NoSuchAlgorithmException, UnsupportedEncodingException, InvalidKeyException {
        //get signStr
        String signStr = "date: " + timeStr + "\n" + "source: " + "source";
        //get sig
        String sig = null;
        Mac mac1 = Mac.getInstance("HmacSHA1");
        byte[] hash;
        SecretKeySpec secretKey = new SecretKeySpec(secret.getBytes("UTF-8"), mac1.getAlgorithm());
        mac1.init(secretKey);
        hash = mac1.doFinal(signStr.getBytes("UTF-8"));
        sig = new BASE64Encoder().encode(hash);
        System.out.println("signValue--->" + sig);
        return sig;
    }

    public static void main(String[] args) {
        String result = "";
        BufferedReader in = null;

        //get current GMT time
        Calendar cd = Calendar.getInstance();
        SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss 'GMT'", Locale.US);
        sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
        String timeStr = sdf.format(cd.getTime());

        String host = "service-o5ikp40z-1255468759.ap-shanghai.apigateway.myqcloud.com";
        String path = "/channel";
        String query = "";
        String url = "https://service-o5ikp40z-1255468759.ap-shanghai.apigateway.myqcloud.com/release";
        url = url + path + "?" + query;
        String source = "source";


        //云市场分配的密钥Id
        String secretId = "xxx";
        //云市场分配的密钥Key
        String secretKey = "xxx";

        try {
            String urlNameString = url;
            URL realUrl = new URL(urlNameString);
            // 打开和URL之间的连接
            URLConnection connection = realUrl.openConnection();
            HttpURLConnection httpUrlCon = (HttpURLConnection)connection;
            // 设置通用的请求属性
            httpUrlCon.setRequestProperty("Host", host);
            httpUrlCon.setRequestProperty("Accept", "text/html, */*; q=0.01");
            httpUrlCon.setRequestProperty("Source", source );
            httpUrlCon.setRequestProperty("Date", timeStr);
            String sig = sign(secretKey,timeStr);
            String authen = "hmac id=\"" + secretId + "\", algorithm=\"hmac-sha1\", headers=\"date source\", signature=\"" + sig + "\"";
            System.out.println("authen --->" + authen);
            httpUrlCon.setRequestProperty("Authorization", authen);
            httpUrlCon.setRequestProperty("X-Requested-With", "XMLHttpRequest");
            httpUrlCon.setRequestProperty("Accept-Encoding", "gzip, deflate, sdch");
            // 建立实际的连接
            httpUrlCon.connect();
            // 获取所有响应头字段
            Map<String, List<String>> map = httpUrlCon.getHeaderFields();
            // 遍历所有的响应头字段
            for (String key : map.keySet()) {
                System.out.println(key + "--->" + map.get(key));
            }
            // 定义 BufferedReader输入流来读取URL的响应
            in = new BufferedReader(new InputStreamReader(
            httpUrlCon.getInputStream()));
            String line;
            while ((line = in.readLine()) != null) {
                result += line;
            }

            System.out.println(result);

        } catch (Exception e) {
            System.out.println("发送GET请求出现异常!" + e);
            e.printStackTrace();
        }
        // 使用finally块来关闭输入流
        finally {
            try {
                if (in != null) {
                    in.close();
                }
            } catch (Exception e2) {
                e2.printStackTrace();
            }
        }
    }
}
/**
 * npm install crypto-js axios
 */
var CryptoJS = require("crypto-js");
var axios = require('axios');

var nowDate = new Date();
var dateTime = nowDate.toGMTString();

var host = "service-o5ikp40z-1255468759.ap-shanghai.apigateway.myqcloud.com";
var path = "/channel";
var query = "";
var url = "https://service-o5ikp40z-1255468759.ap-shanghai.apigateway.myqcloud.com/release";
url = url + path + "?" + query;
var source = "source";

//云市场分配的密钥Id
var secretId = "xxx";
//云市场分配的密钥Key
var secretKey = "xxx";

var auth = "hmac id=\"" + secretId + "\", algorithm=\"hmac-sha1\", headers=\"x-date source\", signature=\"";
var signStr = "x-date: " + dateTime + "\n" + "source: " + source;
var sign = CryptoJS.HmacSHA1(signStr, secretKey)
console.log(sign.toString())
sign = CryptoJS.enc.Base64.stringify(sign)
sign = auth + sign + "\""
console.log(sign)

var instance = axios.create({
    baseURL: url,
    timeout: 5000,
    headers: {
        "Source": source,
        "X-date": dateTime,
        "Authorization": sign
    },
    withCredentials: true
});


instance.get()
    .then(function (response) {
        console.log(response);
    })
    .catch(function (error) {
        console.log(error);
    });

正常返回示例

{
	"showapi_res_code": 0,
	"showapi_res_error": "",
	"showapi_res_body": {
		"totalNum": 44,
		"ret_code": 0,
		"channelList": [
			{
				"channelId": "5572a108b3cdc86cf39001cd",
				"name": "国内焦点"
			},
			{
				"channelId": "5572a108b3cdc86cf39001ce",
				"name": "国际焦点"
			},
			{
				"channelId": "5572a108b3cdc86cf39001cf",
				"name": "军事焦点"
			},
			{
				"channelId": "5572a108b3cdc86cf39001d0",
				"name": "财经焦点"
			},
			{
				"channelId": "5572a108b3cdc86cf39001d1",
				"name": "互联网焦点"
			},
			{
				"channelId": "5572a108b3cdc86cf39001d2",
				"name": "房产焦点"
			},
			{
				"channelId": "5572a108b3cdc86cf39001d3",
				"name": "汽车焦点"
			},
			{
				"channelId": "5572a108b3cdc86cf39001d4",
				"name": "体育焦点"
			},
			{
				"channelId": "5572a108b3cdc86cf39001d5",
				"name": "娱乐焦点"
			},
			{
				"channelId": "5572a108b3cdc86cf39001d6",
				"name": "游戏焦点"
			},
			{
				"channelId": "5572a108b3cdc86cf39001d7",
				"name": "教育焦点"
			},
			{
				"channelId": "5572a108b3cdc86cf39001d8",
				"name": "女人焦点"
			},
			{
				"channelId": "5572a108b3cdc86cf39001d9",
				"name": "科技焦点"
			},
			{
				"channelId": "5572a109b3cdc86cf39001da",
				"name": "社会焦点"
			},
			{
				"channelId": "5572a109b3cdc86cf39001db",
				"name": "国内最新"
			},
			{
				"channelId": "5572a109b3cdc86cf39001dc",
				"name": "台湾最新"
			},
			{
				"channelId": "5572a109b3cdc86cf39001dd",
				"name": "港澳最新"
			},
			{
				"channelId": "5572a109b3cdc86cf39001de",
				"name": "国际最新"
			},
			{
				"channelId": "5572a109b3cdc86cf39001df",
				"name": "军事最新"
			},
			{
				"channelId": "5572a109b3cdc86cf39001e0",
				"name": "财经最新"
			},
			{
				"channelId": "5572a109b3cdc86cf39001e1",
				"name": "理财最新"
			},
			{
				"channelId": "5572a109b3cdc86cf39001e2",
				"name": "宏观经济最新"
			},
			{
				"channelId": "5572a109b3cdc86cf39001e3",
				"name": "互联网最新"
			},
			{
				"channelId": "5572a109b3cdc86cf39001e4",
				"name": "房产最新"
			},
			{
				"channelId": "5572a109b3cdc86cf39001e5",
				"name": "汽车最新"
			},
			{
				"channelId": "5572a109b3cdc86cf39001e6",
				"name": "体育最新"
			},
			{
				"channelId": "5572a10ab3cdc86cf39001e7",
				"name": "国际足球最新"
			},
			{
				"channelId": "5572a10ab3cdc86cf39001e8",
				"name": "国内足球最新"
			},
			{
				"channelId": "5572a10ab3cdc86cf39001e9",
				"name": "CBA最新"
			},
			{
				"channelId": "5572a10ab3cdc86cf39001ea",
				"name": "综合体育最新"
			},
			{
				"channelId": "5572a10ab3cdc86cf39001eb",
				"name": "娱乐最新"
			},
			{
				"channelId": "5572a10ab3cdc86cf39001ec",
				"name": "电影最新"
			},
			{
				"channelId": "5572a10ab3cdc86cf39001ed",
				"name": "电视最新"
			},
			{
				"channelId": "5572a10ab3cdc86cf39001ee",
				"name": "游戏最新"
			},
			{
				"channelId": "5572a10ab3cdc86cf39001ef",
				"name": "教育最新"
			},
			{
				"channelId": "5572a10ab3cdc86cf39001f0",
				"name": "女人最新"
			},
			{
				"channelId": "5572a10ab3cdc86cf39001f1",
				"name": "美容护肤最新"
			},
			{
				"channelId": "5572a10ab3cdc86cf39001f2",
				"name": "情感两性最新"
			},
			{
				"channelId": "5572a10ab3cdc86cf39001f3",
				"name": "健康养生最新"
			},
			{
				"channelId": "5572a10ab3cdc86cf39001f4",
				"name": "科技最新"
			},
			{
				"channelId": "5572a10bb3cdc86cf39001f5",
				"name": "数码最新"
			},
			{
				"channelId": "5572a10bb3cdc86cf39001f6",
				"name": "电脑最新"
			},
			{
				"channelId": "5572a10bb3cdc86cf39001f7",
				"name": "科普最新"
			},
			{
				"channelId": "5572a10bb3cdc86cf39001f8",
				"name": "社会最新"
			}
		]
	}
}
                        

失败返回示例

{
  "showapi_res_code": -1,
  "showapi_res_error": "失败信息",
  "showapi_res_body": {}
}

返回码定义

返回码
返回信息
描述
无参数
产品详情

商品详情

b309e89207f9eae1297407245efabba8.jpg

每10分钟刷新。新闻API接口,包括多个频道的最新新闻,有国内焦点、国际焦点、军事焦点、财经焦点、互联网焦点、房产焦点、汽车焦点、体育焦点、娱乐焦点、游戏焦点等等。


【输入参数】
82bef1701311c69ff5aa1b78a3c9314f.png

【返回参数】
f7fcd6053227bfe90321ffc9a930ad46.png

【调用实例】
bb44ccbe400b204794ebe8c79e94c1ad.png


0ea168597d1a6d21b120353e89096031.jpg


常见问题:

  1.接口怎么对接腾讯云API?

       答:登录腾讯云、根据用量和需求购买相应接口的套餐、获取腾讯云的 secret_id 和 secret_key、开发人员根据“请求示例”调试接口,调试请参考:https://cloud.tencent.com/document/product/628/11782,最后上线生产环境。 


2.售后与服务时间是怎样的?

       答:售后时间:9:00-17:00,技术服务时间:全天24小时,节假日不休。售后、技术服务电话:400-9988-033

评价详情
暂无评价
购买记录
联系电话

4009988033

联系客服
请提前登录QQ,以获得更好体验

秀派技术客服

服务时间

9:00-18:00

联系邮箱

2802673087@qq.com

9
立即购买
联系方式

联系电话

4009988033

服务时间

9:00-18:00

联系邮箱

2802673087@qq.com
必须同意使用协议才可购买