从python代码插入moment.insert [英] moment.insert from python code
问题描述
creds = StorageByKeyName(Credentials, '##myid##', 'credentials').get()
plus_service = util.create_service('plus', 'v1', creds)
moment = {"type":"http://schemas.google.com/AddActivity",
"target": {
"id": "target-id-1",
"type":"http://schemas.google.com/AddActivity",
"name": "The Google+ Platform",
"description": "A page that describes just how awesome Google+ is!",
"image": "https://developers.google.com/+/plugins/snippet/examples/thing.png"
}
}
google_request = plus_service.moments().insert(userId='##myid##', collection='vault', body=moment)
result = google_request.execute()
其中## myid ##是用户的Google ID,具有以下响应:
{u'id': u'Eg0xMzc2NTUxNTU3NDkwGJXv34n_2r7nKTICEBRCBxi-ptG5vw1KEPJcM5xKZRfHSKJ91sYVeyA', u'kind': u'plus#moment', u'type': u'http://schemas.google.com/AddActivity', u'target': {u'name': u'The Google+ Platform', u'kind': u'plus#itemScope', u'id': u'target-id-1', u'image': u'https://developers.google.com/+/plugins/snippet/examples/thing.png', u'description': u'A page that describes just how awesome Google+ is!'}, u'result': {u'kind': u'plus#itemScope'}}
我没有返回错误,但是我的用户G +个人资料或活动中看不到任何内容. 我究竟做错了什么?我应该在哪里看到这项活动?
此外,如果我要求提供以下活动列表:
result = plus_service.moments().list(userId ='## myid ##',collection ='vault').execute()
我可以看到以前发布的活动,但在Google+帐户上仍然看不到.
预先感谢
如果转到Profile -> About
,则在个人资料底部应有一个标题为Apps
的区域.您的应用应以您在开发人员控制台中为其指定的名称显示在此处.您可以单击应用程序的名称,并查看该应用程序发送的所有时刻.
您还可以通过 https://plus.google来访问此列表以及管理授权. com/apps
i am testing with the G+ api in order to post a moment visible on the user timeline. This is the python code i'm using:
creds = StorageByKeyName(Credentials, '##myid##', 'credentials').get()
plus_service = util.create_service('plus', 'v1', creds)
moment = {"type":"http://schemas.google.com/AddActivity",
"target": {
"id": "target-id-1",
"type":"http://schemas.google.com/AddActivity",
"name": "The Google+ Platform",
"description": "A page that describes just how awesome Google+ is!",
"image": "https://developers.google.com/+/plugins/snippet/examples/thing.png"
}
}
google_request = plus_service.moments().insert(userId='##myid##', collection='vault', body=moment)
result = google_request.execute()
where ##myid## is the google id for the user with the following response:
{u'id': u'Eg0xMzc2NTUxNTU3NDkwGJXv34n_2r7nKTICEBRCBxi-ptG5vw1KEPJcM5xKZRfHSKJ91sYVeyA', u'kind': u'plus#moment', u'type': u'http://schemas.google.com/AddActivity', u'target': {u'name': u'The Google+ Platform', u'kind': u'plus#itemScope', u'id': u'target-id-1', u'image': u'https://developers.google.com/+/plugins/snippet/examples/thing.png', u'description': u'A page that describes just how awesome Google+ is!'}, u'result': {u'kind': u'plus#itemScope'}}
I got no error back but i cannot see anything in my user G+ profile or activities. What am i doing wrong? Where am i supposed to see this activity?
Moreover, if i ask for the list of activities such as:
result = plus_service.moments().list(userId='##myid##', collection='vault').execute()
i can see the previously posted activities but still nothing on the G+ account.
Thanks in advance
If you go to Profile -> About
there should be a section towards the bottom of your profile with the title Apps
. Your app should appear here under the name you gave it in the Developer's Console. You can click on the name of the app and see all the moments that were sent by that app.
You can also get to this list, as well as manage the authorizations, via https://plus.google.com/apps
这篇关于从python代码插入moment.insert的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!