1

我需要使用 Python 的 API 包装器将图像上传到 Photobucket。我可以得到 request_token 和 request_token_secret,但不能得到最终的 access_token 和 access_token_secret。相反,我收到以下错误消息:

pbapi.error.PbApiError: (): Token 和 Token Secret 没有响应

我得到的响应如下:

<?xml version="1.0" encoding="UTF-8"?>
<response>
    <status>Exception</status>
    <message>Authentication failed no token</message>
    <code>7</code>
    <format>xml</format>
    <method>POST</method>
    <timestamp>1355787388</timestamp>
</response>
<!-- phx1api05 @ Mon, 17 Dec 2012 16:36:28 -0700 -->

这是我的代码:

api = pbapi.PbApi(API_KEY, API_SECRET)
api.pb_request.connection.cache = None

# Getting request token
api.reset().login().request().post().load_token_from_response()

# Requesting user permission (you have to login with your account)
webbrowser.open_new_tab(api.login_url)
raw_input("Press Enter when you finished access permission. ")

#Getting oAuth token
#api.reset().login().access().post().load_token_from_response()
print api.reset().login().access().post().response_string

请帮忙。

4

1 回答 1

0

Photobucket 是一个极其困难的提供者,因为它们重定向端点的方式。但是我有点惊讶他们自己的包装不起作用。我会推荐rauth,但它不会开箱即用:您必须将签名对象子类化,该对象手动重载要签名的 URL,即将其设置为'api.photobucket.com'然后将您的自定义签名对象传递给会话构造函数。这是可行的,但有点混乱。我在工作中为一个项目工作,但我现在没有可以为您提供的示例。

于 2013-03-28T22:49:37.193 回答