【问题标题】:REST api 'The gurdian' get image URLREST api 'The Guardian' 获取图片 URL
【发布时间】:2017-04-04 21:25:05
【问题描述】:

我正在开发一个新闻应用程序,它使用 RESTapi http://open-platform.theguardian.com/explore/从“守护者”获取数据

 http://content.guardianapis.com/search?page=20&q=business%20OR%20sport&api-key={myKey}

我会收到类似这样的回复

{
"response": {
    "status": "ok",
    "userTier": "developer",
    "total": 80009,
    "startIndex": 191,
    "pageSize": 10,
    "currentPage": 20,
    "pages": 8001,
    "orderBy": "relevance",
    "results": [{
        "id": "sport/2016/aug/03/lizzie-armitstead-responds-statement-twitter-missed-tests-olympics-rio",
        "type": "article",
        "sectionId": "sport",
        "sectionName": "Sport",
        "webPublicationDate": "2016-08-03T11:14:46Z",
        "webTitle": "Lizzie Armitstead hits back: I love my sport but I would never cheat for it",
        "webUrl": "https://www.theguardian.com/sport/2016/aug/03/lizzie-armitstead-responds-statement-twitter-missed-tests-olympics-rio",
        "apiUrl": "https://content.guardianapis.com/sport/2016/aug/03/lizzie-armitstead-responds-statement-twitter-missed-tests-olympics-rio",
        "isHosted": false
    }, {
        "id": "sport/2016/apr/03/mark-bonar-doctor-at-centre-of-doping-allegations-in-sport",
        "type": "article",
        "sectionId": "sport",
        "sectionName": "Sport",
        "webPublicationDate": "2016-04-03T14:10:50Z",
        "webTitle": "Mark Bonar: doctor at centre of doping allegations in sport",
        "webUrl": "https://www.theguardian.com/sport/2016/apr/03/mark-bonar-doctor-at-centre-of-doping-allegations-in-sport",
        "apiUrl": "https://content.guardianapis.com/sport/2016/apr/03/mark-bonar-doctor-at-centre-of-doping-allegations-in-sport",
        "isHosted": false
    }, {
        "id": "sport/blog/2016/apr/22/the-joy-of-six-sporting-tics",
        "type": "article",
        "sectionId": "sport",
        "sectionName": "Sport",
        "webPublicationDate": "2016-04-22T09:15:02Z",
        "webTitle": "The Joy of Six: sporting tics",
        "webUrl": "https://www.theguardian.com/sport/blog/2016/apr/22/the-joy-of-six-sporting-tics",
        "apiUrl": "https://content.guardianapis.com/sport/blog/2016/apr/22/the-joy-of-six-sporting-tics",
        "isHosted": false
    }, {
        "id": "business/2016/sep/20/sports-direct-bows-to-pressure-and-agrees-to-independent-review",
        "type": "article",
        "sectionId": "business",
        "sectionName": "Business",
        "webPublicationDate": "2016-09-20T09:58:23Z",
        "webTitle": "Sports Direct bows to pressure and agrees to independent review",
        "webUrl": "https://www.theguardian.com/business/2016/sep/20/sports-direct-bows-to-pressure-and-agrees-to-independent-review",
        "apiUrl": "https://content.guardianapis.com/business/2016/sep/20/sports-direct-bows-to-pressure-and-agrees-to-independent-review",
        "isHosted": false
    }]
}
}

我需要为每个标题添加一张主图片;但响应数据不包含任何图像 URL。是否可以使用任何方法获取图像 URL;请帮我解决这个问题...

【问题讨论】:

    标签: android rest


    【解决方案1】:

    您必须在请求 URL 中包含 &show-fields=thumbnail,如下所示: http://content.guardianapis.com/search?page=20&q={query}&api-key={myKey}&show-fields=thumbnail

    【讨论】:

    • 如何在没有搜索查询的情况下获取图片和头条新闻?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-12-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-31
    相关资源
    最近更新 更多