android - Facebook Graph API request error when using HTTP POST / DELETE method -
i'm developing android app integrated facebook sdk.
first i'm fetching feeds of facebook page using graph api, working fine. want allow users & post comments against each feed.
i'm using following code snippet like
bundle parameters = new bundle(); parameters.putstring("access_token", access_token); string response = null; string id = <target feed id>; try { response = facebook.request(id+"/likes", parameters, "post"); } catch (malformedurlexception e) { // todo auto-generated catch block e.printstacktrace(); } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); } log.i("fb output", ""+response);
but i'm getting nullpointerexception @ following line:
response = facebook.request(id+"/likes", parameters, "post");
please note error occurs only when i'm using "post" or "delete" 3rd parameter. instead if i'm using get proper response (which however, won't serve purpose).
also, i've added relevant permissions publish_stream.
is correct syntax making synchronous request using http post method ?
04-25 16:29:08.332: e/androidruntime(710): fatal exception: main 04-25 16:29:08.332: e/androidruntime(710): java.lang.nullpointerexception 04-25 16:29:08.332: e/androidruntime(710): @ java.net.urldecoder.decode(urldecoder.java:130) 04-25 16:29:08.332: e/androidruntime(710): @ java.net.urldecoder.decode(urldecoder.java:68) 04-25 16:29:08.332: e/androidruntime(710): @ com.facebook.android.util.openurl(util.java:186) 04-25 16:29:08.332: e/androidruntime(710): @ com.facebook.android.facebook.requestimpl(facebook.java:806) 04-25 16:29:08.332: e/androidruntime(710): @ com.facebook.android.facebook.request(facebook.java:794) 04-25 16:29:08.332: e/androidruntime(710): @ com.test.myapp.adapters.facebookadapter$1.onclick(facebookadapter.java:107) 04-25 16:29:08.332: e/androidruntime(710): @ android.view.view.performclick(view.java:2408) 04-25 16:29:08.332: e/androidruntime(710): @ android.view.view$performclick.run(view.java:8816) 04-25 16:29:08.332: e/androidruntime(710): @ android.os.handler.handlecallback(handler.java:587) 04-25 16:29:08.332: e/androidruntime(710): @ android.os.handler.dispatchmessage(handler.java:92) 04-25 16:29:08.332: e/androidruntime(710): @ android.os.looper.loop(looper.java:123) 04-25 16:29:08.332: e/androidruntime(710): @ android.app.activitythread.main(activitythread.java:4627) 04-25 16:29:08.332: e/androidruntime(710): @ java.lang.reflect.method.invokenative(native method) 04-25 16:29:08.332: e/androidruntime(710): @ java.lang.reflect.method.invoke(method.java:521) 04-25 16:29:08.332: e/androidruntime(710): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:868) 04-25 16:29:08.332: e/androidruntime(710): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:626) 04-25 16:29:08.332: e/androidruntime(710): @ dalvik.system.nativestart.main(native method)
as indicated on https://developers.facebook.com/docs/reference/api/publishing/,
like given object (if has /likes connection)
and you're not able find /likes connection on https://developers.facebook.com/docs/reference/api/page/
you can't fanpage, , code cause problem
string id = <facebook page id>;