Feedly API和JSON

2024-10-02 08:17:52 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试访问Feedly API来自动收集和共享Facebook组的文章。到目前为止,我甚至还不知道如何使用位于这里的Feedly API包装器:https://github.com/zgw21cn/FeedlyClient

from feedlyclient import FeedlyClient

# Feedly

feedaccess = "removed"
myfeedId = "removed"

con = FeedlyClient()
con.get_feed_content(feedaccess,myfeedId,False,10000)
parsed = json.loads(con)
print json.dumps(parsed)

终端

^{pr2}$

请帮忙。在

第二次尝试

import json
import requests

# Feedly

feedaccess = "REMOVED"
myfeedid = "user/REMOVED/category/tutorial"

def get_feed_content(unreadOnly=None, newerThan=None, count="10",
                         continuation=None,
                         ranked=None):
        """
        return contents of a feed
        :param access_token:
        :param streamId:
        :param unreadOnly:
        :param newerThan:
        :param count:
        :param continuation:
        :param ranked:
        :return:
        """

        headers = {'Authorization': 'OAuth ' + feedaccess}
        quest_url = ('http://cloud.feedly.com/v3/streams/contents')
        params = dict(streamId=myfeedid)
        # Optional parameters
        if unreadOnly is not None:
            params['unreadOnly'] = unreadOnly
        if newerThan is not None:
            params['newerThan'] = newerThan
        if count is not None:
            params['count'] = count
        if continuation is not None:
            params['continuation'] = continuation
        if ranked is not None:
            params['ranked'] = ranked
        res = requests.get(url=quest_url, params=params, headers=headers)
        return res.json()

con = get_feed_content()
print json.dumps(con , indent=4)

终端

{
    "items": [],
    "id": "user/REMOVED/category/tutorial"
}

只返回我的用户凭据。Feedly文档说我可以使用category作为流ID。https://developer.feedly.com/v3/streams/

第三次尝试

import json
import requests
from client import FeedlyClient

# Feedly

feedaccess = "REMOVED"
myfeedid = "user/REMOVED/category/tutorial"
feedcount = "20"
myurl = "http://cloud.feedly.com/v3/streams/contents?streamId=" + myfeedid + "&count=" + feedcount


headers = {'Authorization': 'OAuth ' + feedaccess}
res = requests.get(url=myurl, headers=headers)
con = res.json()
print json.dumps(con , indent=4)

相同的终端响应


Tags: importnonejsongetparamcountparamscon

热门问题