2012-05-21 4 views
2

안녕하세요. 파이썬에 대한 다양한 옵션을 평가하기 시작했습니다.> Twitter api : s.Twython : 예제를 실행하는 중에 오류가 발생했습니다.

Twython 패키지의 예제를 보면서 코드를 작성했지만 항상 같은 오류가 발생합니다.

AttributeError: 'Twython' object has no attribute 'auth' 

포함 된 core_example 파일을 실행해도 동일한 오류가 발생합니다.

"2.0.0"을 git에서 실행 중입니다.

/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python /Users/skjortan/dev/trunk/3rdPartyLibs/twython/core_examples/current_trends.py 
Traceback (most recent call last): 
    File "/Users/skjortan/dev/trunk/3rdPartyLibs/twython/core_examples/current_trends.py", line 5, in <module> 
    trends = twitter.getCurrentTrends() 
    File "/Library/Python/2.7/site-packages/twython-2.0.0-py2.7.egg/twython/twython.py", line 167, in <lambda> 
    return lambda **kwargs: self._constructFunc(key, **kwargs) 
    File "/Library/Python/2.7/site-packages/twython-2.0.0-py2.7.egg/twython/twython.py", line 188, in _constructFunc 
    content = self._request(url, method=method, params=kwargs) 
    File "/Library/Python/2.7/site-packages/twython-2.0.0-py2.7.egg/twython/twython.py", line 205, in _request 
    response = func(url, data=myargs, auth=self.auth) 
AttributeError: 'Twython' object has no attribute 'auth' 

프로세스 종료 코드 1

답변

2

내가 눈치 질문 - 나는 Twython의 저자입니다. 수정 사항은 2.0.1 릴리스에서 커밋되고 푸시되었습니다. 설치를 업데이트하면 더 이상 문제가되지 않습니다.

감사합니다. 불편을 끼쳐 드려 죄송합니다. 2.0.0 릴리스에서 미끄러 진 버그.

0

완료 있지만 정말 어떤 속성이없는 '인증'하지만이 같은 방법이 있습니다

def get_authentication_tokens(self): 
    """Returns an authorization URL for a user to hit.""" 

def get_authorized_tokens(self): 
    """Returns authorized tokens after they go through the auth_url phase.""" 

을 그리고 이것은 장고 - twython의 샘플이 얼마나 저자 인증

def begin_auth(request): 
    """ 
    The view function that initiates the entire handshake. 
    For the most part, this is 100% drag and drop. 
    """ 
    # Instantiate Twython with the first leg of our trip. 
    twitter = Twython(
    twitter_token = settings.TWITTER_KEY, 
    twitter_secret = settings.TWITTER_SECRET, 
    callback_url =  request.build_absolute_uri(reverse('twython_django_oauth.views.thanks'))) 

    # Request an authorization url to send the user to... 
    auth_props = twitter.get_authentication_tokens() 

    # Then send them over there, durh. 
    request.session['request_token'] = auth_props 
    return HttpResponseRedirect(auth_props['auth_url']) 
0

분명히 트위터 API를하고 단지 OAuth를위한 정상적인 로그인을 허용하지 않는, 일 생성 거기에서 트위터와 OAuth를 설정 탭에서 전자 애플리케이션은 OAuth를 설정에서 데이터를 가져 와서에서의 OAuth 방법 :

http://pydoc.net/twython/1.4.5/twython.twitter_endpoints

+0

하지만 기본 검색 및 공개 일정을 얻으려면 인증이 필요하지 않습니다. 아니면 최근에 트위터에 바뀌 었습니까? – Thom

관련 문제