问题
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
回答1:
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
来源:https://stackoverflow.com/questions/18261974/moment-insert-from-python-code