【发布时间】:2014-02-04 10:54:13
【问题描述】:
我需要从我的网站管理屏幕发布到我的页面流。使用Google Plus API 我希望能够添加活动并在我的页面流上共享 URL。然而,正在发生的事情是该帖子出现在我的个人资料页面上,而不是在此个人资料下创建的页面上。下面是我在 Python 中的代码的 sn-p。我尝试使用page_id 而不是“我”,但它给了我一个错误的凭据。我会很感激这方面的帮助,因为我被困住了,在过去的 5 天里一直在尝试不同的事情,但没有任何效果。
OAuth2 成功后,我执行以下操作:
http = httplib2.Http()
http = credentials.authorize(http)
service_plus = build('plus', 'v1', http=http)
service_plus_domain = build('plusDomains', 'v1', http=http)
activity = {
'object': {
'url': 'https://developers.google.com/+/web/snippet/examples/photo',
},
'access': {
'items': [{
'type': 'public'
}],
'domainRestricted': True
}
}
google_request = service_plus_domain.activities().insert(
userId='me', #Trying page_id here gives invalid credentials
body=activity
)
result = google_request.execute()
print result
【问题讨论】:
-
欢迎来到 StackOverflow!我无能为力,但我相信人们想知道您的错误凭据的确切错误。
-
您确定您已获得所有必要的scopes 授权吗?您是否获得了您要发布的个人资料的用户的访问令牌?您可能需要使用service account flow 来获取这些信息。
标签: python api google-plus