import twitter
Api = twitter.api(consumer_key='[gdgfdfhgfuff] ',
consumer_secret='[jhhjf] ',
access_token_key=' [jhvhvvhjvhvhvh]',
access_token_secret='[hvghgvvh] ')
friends=Api.PostUpdate("First Tweet from PYTHON APP ")
错误
Traceback (most recent call last):
File "C:/Python34/t7.py", line 6, in <module>
access_token_secret='[ghfghgghv] ')
TypeError: 'module' object is not callable
答案 0 :(得分:1)
你必须使用
from twitter.api import Api
因为您要导入api
模块形式twitter
包。您必须从api
包中的twitter
模块导入Api
课程。
....
class Api(object):
....
....
def __init__(self,
consumer_key=None,
consumer_secret=None,
access_token_key=None,
access_token_secret=None,
input_encoding=None,
request_headers=None,
cache=DEFAULT_CACHE,
shortner=None,
base_url=None,
stream_url=None,
use_gzip_compression=False,
debugHTTP=False,
requests_timeout=None):
'''Instantiate a new twitter.Api object.
Args:
......
...
答案 1 :(得分:0)
您可以使用此示例代码在Twitter上发布
import tweepy
consumer_key = Your_consumer_key
consumer_secret = Your_consumer_secret
access_token = Your_access_token
access_token_secret = Your_access_token_secret_key
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
single_tweet = 'hello world'
api.update_status(single_tweet)
print "successfully Updated"