oauth 2.0 - how to post in user's Streams using google plus api in java -
i want share information in google plus wall application.and trying moment.insert, getting 400 error . can me
@override public jsonobject getgoogleplusadduseractivities(object token) { token accesstoken = (token) token; oauthservice service = createoauthserviceforgoogleplus(); oauthrequest request = new oauthrequest(method.post,"https://www.googleapis.com/plus/v1/people/me/moments/vault"); request.addquerystringparameter("alt", "json"); service.signrequest(accesstoken, request); jsonobject object=new jsonobject(); try { object.put("kind","plus#moment"); object.put("type","http://schemas.google.com/addactivity"); jsonobject obj1=new jsonobject(); obj1.put("kind", "plus#itemscope"); obj1.put("url","https://plus.google.com/me"); obj1.put("description","sign claim , redeem credits while shopping! "); obj1.put("image","http://invite.png"); obj1.put("contenturl", "www.abcd.com"); obj1.put("thumbnailurl", "http://logo1_favicon.png"); object.putopt("target", obj1);; }catch(exception ex) { ex.printstacktrace(); } request.addpayload(object.tostring()); request.addheader("content-type", "application/json"); system.out.println("request : "+request.getbodycontents()); response response = request.send(); string responsebody = response.getbody(); jsonobject googlejson = null; try { googlejson = new jsonobject(responsebody); } catch (jsonexception e) { system.out.println("can not create json object"); }
getting 400 error ?? can tell me..... wrong ..!!`
it isn't clear documentation, can't provide both target.url
, other target
metadata. opened bug 485 in issue tracking system - please go there , star issue make sure prioritize fix.
if remove target.url
value , add target.id
value, should work.
(as aside, not post in user's stream, post app activity in app moment vault. must manually share activity if choose.)
Comments
Post a Comment