2017-10-16 6 views
0

Feedly API에 액세스하여 기사를 자동으로 수집하고 Facebook 그룹에 공유하려고합니다. 지금까지 내가 여기있는 Feedly의 API의 래퍼를 사용하는 방법을 알아낼도 할 수없는이 : 도와주세요 https://github.com/zgw21cn/FeedlyClientFeedly API 및 JSON

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) 

터미널

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 

.

두 번째 시도

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

그냥 내 사용자 자격 증명을 반환

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) 

TERMINAL. Feedly 문서에 카테고리를 스트림 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) 

동일한 터미널의 응답

+1

올바른 클라이언트 객체를 얻으려면 해당 라이브러리의 추가 정보 지침을 따르지 않은 것 같습니다. –

+0

개발자 포럼에서 ReadMe에 명시된 코드를 적용하여 액세스 토큰을 얻는 방법에 대한 의견을 보았습니다. ReadMe 자체를 이해하지 못했습니다. 제공된 링크는 ID & 키라고 불리는 곳으로 연결되지 않습니다. 매달 게시/업데이트되는 고객 ID 및 비밀이 포럼에 있습니다. Feedly는 개발자를위한 액세스 토큰을 생성하며, 수년 전부터 이러한 주석이 충분하기 때문에 충분히 유용하다고 생각했습니다. 단계별 지시에 의한 더 명확한 단계가 인정 될 것입니다. 내가 열쇠를 가져 왔다고합시다. 그리고 뭐? 어디에서 그들을 연결합니까? –

답변

0

세 번째 시도했다. 내 카테고리 이름에 대문자가있었습니다. 튜토리얼이 아닌 자습서 여야합니다. 코드는 원래 게시물을 참조하십시오.