国家地理National Geographic的API接口

发布于 / 教程 / 0 条评论

这实际上是两个接口:一是来自国家地理National Geographic的API接口,返回每日推荐的图文内容,二是来自华夏国家地理的API接口,返回的内容与华夏国家地理APP内容一致

National Geographic

此接口需要AppKey的授权方能调用。

接口地址


https://api-cn.berryapi.net/ngo/

请求方式

该接口使用GET方式即可

请求示例

获取页面内容:


https://api-cn.berryapi.net/ngo/?AppKey={$AppKey}&p={$p}

获取单个内容:


https://api-cn.berryapi.net/ngo/post/?AppKey={$AppKey}&albumid={$id}

参数说明

P参数为请求的页码数
albumid为单个内容的id,由页面内容返回: "album"=>"id"

返回示例

页面内容:


{
    "total": "1459",
    "page": "2",
    "pagecount": "15",
    "album": [
        {
            "id": "1980",
            "title": "2018-05-26 每日精选",
            "url": "http://pic01.bdatu.com/Upload/appsimg/1526894872.jpg",
            "addtime": "2018-05-26 00:04:00",
            "adshow": "NO",
            "fabu": "YES",
            "encoded": "1",
            "amd5": "8d27c547b478fc490a0955265d137036",
            "sort": "1980",
            "ds": "1",
            "timing": "1",
            "timingpublish": "2018-05-26 00:00:00"
        },
        {
            "id": "1979",
            "title": "2018-05-25 每日精选",
            "url": "http://pic01.bdatu.com/Upload/appsimg/1526893893.jpg",
            "addtime": "2018-06-05 12:11:05",
            "adshow": "NO",
            "fabu": "YES",
            "encoded": "1",
            "amd5": "63551f32042c47916d1f15a314917682",
            "sort": "1979",
            "ds": "1",
            "timing": "1",
            "timingpublish": "2018-05-25 00:00:00"
        },
        {
            "id": "1977",
            "title": "2018-05-24〈乾涸的湖泊〉",
            "url": "http://pic01.bdatu.com/Upload/appsimg/1526012021.jpg",
            "addtime": "2018-05-24 00:04:00",
            "adshow": "NO",
            "fabu": "YES",
            "encoded": "1",
            "amd5": "3621c3a5cd83fc3513278a4bcdfda08a",
            "sort": "1977",
            "ds": "1",
            "timing": "1",
            "timingpublish": "2018-05-24 00:00:00"
        },
       ...
    ]
}

单个内容:


{
    "counttotal": "11",
    "picture": [
        {
            "id": "18595",
            "albumid": "1995",
            "title": "蕾丝影子",
            "content": "女孩在蕾丝影子里作著白日梦。她躲在这些影子里,避免让人看见她的恐惧与不安。",
            "url": "http://pic01.bdatu.com/Upload/picimg/1527826163.jpg",
            "size": "142431",
            "addtime": "2018-06-01 12:09:25",
            "author": "Candice Brophy",
            "thumb": "http://pic01.bdatu.com/Upload/picimg/1527826163.jpg",
            "encoded": "1",
            "weburl": "http://",
            "type": "pic",
            "yourshotlink": "http://yourshot.nationalgeographic.com/photos/11562886/",
            "copyright": "",
            "pmd5": "cca930c48f90fa0a294cd0220a8ee1dc",
            "sort": "18595"
        },
        {
            "id": "18594",
            "albumid": "1995",
            "title": "小猫熊",
            "content": "当她姐姐去朋友家过夜时,她终于有机会戴一下她姐姐的「猫熊帽」了;)",
            "url": "http://pic01.bdatu.com/Upload/picimg/1527826139.jpg",
            "size": "182089",
            "addtime": "2018-06-01 12:09:01",
            "author": "Joanna Grzyl",
            "thumb": "http://pic01.bdatu.com/Upload/picimg/1527826139.jpg",
            "encoded": "1",
            "weburl": "http://",
            "type": "pic",
            "yourshotlink": "http://yourshot.nationalgeographic.com/photos/11562893/",
            "copyright": "",
            "pmd5": "aed164fb74cb7233f2c6d6f2e7271b04",
            "sort": "18594"
        },
    ...

    ]
}

华夏国家地理

此接口需要AppKey授权方能调用。

接口地址

华夏国家地理接口有3个:
1.获取分类id的接口


https://api-cn.berryapi.net/ngochina/cat/?AppKey={$AppKey}

接口返回:


{
    "requestCode": -1,
    "requestCodeName": null,
    "type": "info",
    "code": 0,
    "codeName": null,
    "message": "查询成功!",
    "data": [
        {
            "id": 1,
            "type": 0,
            "name": "推荐",
            "seqNo": 1,
            "banners": [
              ...
            ],
            "discatArticles": {
                "pagination": {
                    "totalCount": 182,
                    "pageSize": 10,
                    "pageNumber": 1,
                    "pageIndexRange": {
                        "from": 0,
                        "to": 9
                    },
                    "pageIndexFrom": 0
                },
                "rows": [
                    {
                        "id": 311,
                        "discatId": 1,
                        "articleId": 287,
                        "seqNo": 285,
                        "logoBrowseUrl": "http://static.ngchina.cn/repo/image/logo/2018/06/08/0cff6d4c-e937-40ab-bb77-fc22a1b1b6fc.jpg",
                        "articleTitle": "世界海洋日,摄影大师为你献上视觉盛宴",
                        "articleAtlas": null,
                        "pubDay": "2018-06-08"
                    },
                    {
                        "id": 308,
                        "discatId": 1,
                        "articleId": 284,
                        "seqNo": 282,
                        "logoBrowseUrl": "http://static.ngchina.cn/repo/image/logo/2018/06/07/afc796d6-d439-4ab1-bb55-6502b6a85dbd.jpg",
                        "articleTitle": "支招:如何以家庭为单位减少塑料的使用",
                        "articleAtlas": null,
                        "pubDay": "2018-06-07"
                    },
                   ...
                ]
            },
            "discatAtlas": null,
            "state": false,
            "articleId": null,
            "createTime": "2018-01-16 14:44:06",
            "ts": "2018-01-21 17:47:40"
        },
        {
            "id": 2,
            "type": 1,
            "name": "摄影",
            "seqNo": 2,
            "banners": [],
            "discatArticles": null,
            "discatAtlas": {
                "pagination": {
                    "totalCount": 51,
                    "pageSize": 10,
                    "pageNumber": 1,
                    "pageIndexRange": {
                        "from": 0,
                        "to": 9
                    },
                    "pageIndexFrom": 0
                },
                "rows": [
                    {
                        "id": 89,
                        "discatId": 2,
                        "atlasId": 112,
                        "seqNo": 79,
                        "fileBrowseUrl": "http://static.ngchina.cn/repo/image/misc/2018/06/07/86453fae-a539-4ecd-b231-9d7a688e3945.jpg",
                        "atlasName": "老照片:那些年《国家地理》拍摄的昆虫写真",
                        "imgWidth": 660,
                        "imgHeight": 495,
                        "content": ""
                    },
                    {
                        "id": 88,
                        "discatId": 2,
                        "atlasId": 110,
                        "seqNo": 78,
                        "fileBrowseUrl": "http://static.ngchina.cn/repo/image/misc/2018/05/28/8e58eba0-86ca-4454-bbda-89328238803e.jpg",
                        "atlasName": null,
                        "imgWidth": 660,
                        "imgHeight": 495,
                        "content": ""
                    },
                 ...
                ]
            },
            "state": false,
            "articleId": null,
            "createTime": "2018-01-16 14:44:06",
            "ts": "2018-01-21 17:47:48"
        },
        {
            "id": 3,
            "type": 0,
            "name": "视频",
            "seqNo": 3,
            "banners": [
                {
                    "id": 18,
                    "discatId": 3,
                    "imageUuid": "f7a6c845-b0e8-47fe-961f-644163d25a86",
                    "imageUsage": "image.logo",
                    "imagePath": "2018/06/05/aac50d9e-b298-4684-a77f-2c76be035359.jpg",
                    "seqNo": 6,
                    "url": "#article?id=278",
                    "name": "国家地理:塑料是什么?塑料如何生产?",
                    "meno": null,
                    "fileBrowseUrl": "http://static.ngchina.cn/repo/image/logo/2018/06/05/aac50d9e-b298-4684-a77f-2c76be035359.jpg",
                    "disCatId": 3,
                    "createTime": "2018-02-05 10:48:25",
                    "ts": "2018-02-05 10:48:25"
                },
            ...
            ],
            "discatArticles": {
                "pagination": {
                    "totalCount": 82,
                    "pageSize": 10,
                    "pageNumber": 1,
                    "pageIndexRange": {
                        "from": 0,
                        "to": 9
                    },
                    "pageIndexFrom": 0
                },
                "rows": [
                    {
                        "id": 310,
                        "discatId": 3,
                        "articleId": 286,
                        "seqNo": 284,
                        "logoBrowseUrl": "http://static.ngchina.cn/repo/image/logo/2018/06/08/173d409a-6509-47ca-9dd8-d3e56e4baaa8.jpg",
                        "articleTitle": "国家地理:震惊!你所吃的海鲜可能在“垃圾”中生活",
                        "articleAtlas": null,
                        "pubDay": "2018-06-08"
                    },
                 ...

                ]
            },
            "discatAtlas": null,
            "state": false,
            "articleId": null,
            "createTime": "2018-01-21 17:47:57",
            "ts": "2018-02-02 18:13:18"
        },
        {
            "id": 4,
            "type": 0,
            "name": "活动",
            "seqNo": 4,
            "banners": [
                {
                    "id": 21,
                    "discatId": 4,
                    "imageUuid": "6cb3ec96-85de-477d-9bac-60f19a191811",
                    "imageUsage": "image.logo",
                    "imagePath": "2018/05/17/87e5cc7e-cb2e-4398-83de-9602667db9b9.jpg",
                    "seqNo": 9,
                    "url": "http://syds.ngchina.cn/",
                    "name": null,
                    "meno": null,
                    "fileBrowseUrl": "http://static.ngchina.cn/repo/image/logo/2018/05/17/87e5cc7e-cb2e-4398-83de-9602667db9b9.jpg",
                    "disCatId": 4,
                    "createTime": "2018-02-11 10:42:05",
                    "ts": "2018-02-11 10:42:05"
                },
           ...
            ],
            "discatArticles": {
                "pagination": {
                    "totalCount": 5,
                    "pageSize": 10,
                    "pageNumber": 1,
                    "pageIndexRange": {
                        "from": 0,
                        "to": 4
                    },
                    "pageIndexFrom": 0
                },
                "rows": [
                    {
                        "id": 257,
                        "discatId": 4,
                        "articleId": 235,
                        "seqNo": 232,
                        "logoBrowseUrl": "http://static.ngchina.cn/repo/image/logo/2018/05/17/1d560e19-987b-4932-9724-596567adde42.jpg",
                        "articleTitle": "2018美国《国家地理》全球摄影大赛中国区正式启动",
                        "articleAtlas": null,
                        "pubDay": "2018-05-17"
                    },
                   ...
                ]
            },
            "discatAtlas": null,
            "state": false,
            "articleId": null,
            "createTime": "2018-01-21 17:48:04",
            "ts": "2018-02-02 18:13:23"
        }
    ]
}

2.获取某个分类id下的页面内容接口
拼接接口1 "data"=>"id" 为{$catid},{$page}为请求的页码数,{$pageSize}为每页返回数量


https://api-cn.berryapi.net/ngochina/?AppKey={$AppKey}&catid={$catid}&page={$page}&pageSize={$pageSize}

接口返回:


{
    "requestCode": -1,
    "requestCodeName": null,
    "type": "info",
    "code": 0,
    "codeName": null,
    "message": "查询成功!",
    "data": {
        "id": 1,
        "type": 0,
        "name": "推荐",
        "seqNo": 1,
        "banners": [
            {
                "id": 22,
                "discatId": 1,
                "imageUuid": "4a86427c-78dd-474d-bca9-81a1bf0f90f9",
                "imageUsage": "image.logo",
                "imagePath": "2018/06/08/9f5223a0-158a-407a-9bd0-3511867f633e.jpg",
                "seqNo": 12,
                "url": "#article?id=287",
                "name": "世界海洋日,摄影大师为你献上视觉盛宴",
                "meno": null,
                "fileBrowseUrl": "http://static.ngchina.cn/repo/image/logo/2018/06/08/9f5223a0-158a-407a-9bd0-3511867f633e.jpg",
                "disCatId": 1,
                "createTime": "2018-02-11 16:00:22",
                "ts": "2018-02-11 16:00:22"
            },
            ...
        ],
        "discatArticles": {
            "pagination": {
                "totalCount": 182,
                "pageSize": 10,
                "pageNumber": 1,
                "pageIndexRange": {
                    "from": 0,
                    "to": 9
                },
                "pageIndexFrom": 0
            },
            "rows": [
                {
                    "id": 311,
                    "discatId": 1,
                    "articleId": 287,
                    "seqNo": 285,
                    "logoBrowseUrl": "http://static.ngchina.cn/repo/image/logo/2018/06/08/0cff6d4c-e937-40ab-bb77-fc22a1b1b6fc.jpg",
                    "articleTitle": "世界海洋日,摄影大师为你献上视觉盛宴",
                    "articleAtlas": null,
                    "pubDay": "2018-06-08"
                },
             ...
            ]
        },
        "discatAtlas": null,
        "state": false,
        "articleId": null,
        "createTime": "2018-01-16 14:44:06",
        "ts": "2018-01-21 17:47:40"
    }
}

3.获取单个内容详情的接口
拼接在接口2中获得的单个内容的articleId,在banner图中articleId为"url": "#article?id=287"


https://api-cn.berryapi.net/ngochina/post/?AppKey={$AppKey}&articleId={$articleId}

接口返回:


{
    "requestCode": -1,
    "requestCodeName": null,
    "type": "info",
    "code": 0,
    "codeName": null,
    "message": null,
    "data": {
        "id": 287,
        "discatId": null,
        "articleType": 0,
        "title": "世界海洋日,摄影大师为你献上视觉盛宴",
        "subTitle": null,
        "introduction": null,
        "editor": "华夏地理",
        "source": "华夏地理",
        "content": "...",
        "imageUuid": null,
        "imageUsage": null,
        "imagePath": null,
        "logoUuid": "1b37de29-c2ae-4bb8-b560-c5ad1668cd81",
        "logoUsage": "image.logo",
        "logoPath": "2018/06/08/0cff6d4c-e937-40ab-bb77-fc22a1b1b6fc.jpg",
        "fileUuid": "e4bb33b7-44e2-4a08-a937-740107023bc3",
        "fileUsage": "file.ziliao",
        "filePath": "2018/06/08/85b937db-fed7-4f5d-9fe8-76557737a166.mp3",
        "wwwFrom": null,
        "creatorName": "华夏地理",
        "disabled": false,
        "deleted": false,
        "timeInterval": null,
        "fileBrowseUrl": "http://static.ngchina.cn/repo/image/logo/2018/06/08/0cff6d4c-e937-40ab-bb77-fc22a1b1b6fc.jpg",
        "audioBrowseUrl": "http://static.ngchina.cn/repo/file/ziliao/2018/06/08/85b937db-fed7-4f5d-9fe8-76557737a166.mp3",
        "logoBrowseUrl": "http://static.ngchina.cn/repo/image/logo/2018/06/08/0cff6d4c-e937-40ab-bb77-fc22a1b1b6fc.jpg",
        "memberComments": [
            {
                "id": 307,
                "articleId": 287,
                "memberId": 9674,
                "userName": "13478316558",
                "content": "尽情地享受兴趣所带来的快乐吧!",
                "seqNo": 255,
                "headImageUrl": null,
                "replyContent": null,
                "memberCommentReply": null,
                "ts": "2018-06-08 22:29:56"
            }
        ],
        "articleAtlas": [],
        "pubDay": "2018-06-08",
        "createTime": "2018-06-08 16:45:30",
        "ts": "2018-06-08 16:50:45",
        "changeTime": null,
        "indexTime": null
    }
}

提示

单篇文章解析出来如果含有视频可以把链接提交到视频解析网解析,也可以参照BerryAPI其他接口完成视频解析,

比如:在articleId=266文章中找到一个加载的视频地址:


src="https://v.miaopai.com/iframe?scid=ynobfgTu~-82SNlkXZqHh6WFZPU2nCpOXjDrRQ__"

其中https://v.miaopai.com/iframe?scid=ynobfgTu~-82SNlkXZqHh6WFZPU2nCpOXjDrRQ__地址为秒拍视频的地址;scid即视频id ,参考秒拍视频解析拼接视频url为:
http://www.miaopai.com/show/ynobfgTu~-82SNlkXZqHh6WFZPU2nCpOXjDrRQ__.htm
解析的视频结果为:

https://bsyqncdn.miaopai.com/stream/ynobfgTu~-82SNlkXZqHh6WFZPU2nCpOXjDrRQ___0_1527760772.mp4?ssig=69bc8f690eedd876d35b4a0f2e0963b3&time_stamp=1528631376141&f=/ynobfgTu~-82SNlkXZqHh6WFZPU2nCpOXjDrRQ___0_1527760772.mp4
结果预览:


定制开发

接受各种定制开发,微信咨询:

前往查看

赞助支持

转载原创文章请注明,转载自: LYLARES BLOG » 国家地理National Geographic的API接口

    1. @GalaxyOcean 试试这个:
      
      https://api.cn.berryapi.net/docs.html
      
      1. @lylares https://api.cn.berryapi.net/docs.html 这个网站里好像没有获取AppKey的方法
        1. @GalaxyOcean 试试Test201901