首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Feedly & JSON

Feedly & JSON
EN

Stack Overflow用户
提问于 2017-10-16 09:40:31
回答 1查看 1.6K关注 0票数 0

我正在尝试访问Feedly,以便自动将文章收集和共享给一个Facebook组。到目前为止,我还没有弄清楚如何使用位于这里的Feedly包装器:https://github.com/zgw21cn/FeedlyClient

代码语言:javascript
复制
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)

终端

代码语言:javascript
复制
PS D:\Python Projects\Python 2\fbauto> & python "d:/Python Projects/Python 2/fbauto/feedlytest.py"
Traceback (most recent call last):
  File "d:/Python Projects/Python 2/fbauto/feedlytest.py", line 8, in <module>
    con = FeedlyClient.get_feed_content(feedaccess,myfeedId,False,10000)
TypeError: unbound method get_feed_content() must be called with FeedlyClient instance as first argument (got str instance instead)
PS D:\Python Projects\Python 2\fbauto> & python "d:/Python Projects/Python 2/fbauto/feedlytest.py"
Traceback (most recent call last):
  File "d:/Python Projects/Python 2/fbauto/feedlytest.py", line 9, in <module>
    con.get_feed_content(feedaccess,myfeedId,False,10000)
  File "d:\Python Projects\Python 2\fbauto\feedlyclient.py", line 75, in get_feed_content
    return res.json()
  File "C:\Python27\lib\site-packages\requests\models.py", line 892, in json
    return complexjson.loads(self.text, **kwargs)
  File "C:\Python27\lib\json\__init__.py", line 339, in loads
    return _default_decoder.decode(s)
  File "C:\Python27\lib\json\decoder.py", line 364, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Python27\lib\json\decoder.py", line 382, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

请帮帮忙。

第二次尝试

代码语言:javascript
复制
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)

终端

代码语言:javascript
复制
{
    "items": [],
    "id": "user/REMOVED/category/tutorial"
}

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

第三次尝试

代码语言:javascript
复制
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)

同端响应

EN

回答 1

Stack Overflow用户

发布于 2017-10-17 08:48:31

第三次尝试成功了。我的类别名中有大写。它应该是教程而不是教程。请查看原始帖子的代码。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46767221

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档