我正在开发一个与facebook集成的Android应用程序(我非常新)。我可以成功实现登录/注销部分。
现在我需要我的Android应用程序在特定页面上发布(文本)。我不知道如何处理这个问题。我试着阅读所有类似的帖子。我使用" facebook.request(page_id + / feed,参数," POST")" ,这总是返回一个空指针异常,因为不推荐request(feed,parameters,"POST")
方法(下面写的代码)。
我试图按照facebook sdk教程,其中涉及access_tokens和graph apis,这让我更加困惑。
我甚至不知道如何处理这个问题。如果有人可以指导我,那么对我来说这将是一件非常有帮助的事情。
谢谢。
try{
Tring response = facebook.request("me");
Bundle parameters = new Bundle();
parameters.putString("message", msg);
parameters.putString("description", "test test test");
// parameters.putByteArray("message", msg);
response = facebook.request("me/feed", parameters, "POST");
Log.d("Tests", "got response: " + response);
if (response == null || response.equals("")
|| response.equals("false")) {
Log.v("Error", "Blank response");
}else{
}
} catch (Exception e) {
e.printStackTrace();
}
}
LOGCAT
01-07 20:14:21.330 7830-7835/com.example.kai.gameofapis2 D/dalvikvm﹕ Debugger has detached; object registry had 1 entries
01-07 20:16:21.460 11583-11583/com.example.kai.gameofapis2 V/Zygote﹕ Switching descriptor 33 to /dev/null
01-07 20:16:21.460 11583-11583/com.example.kai.gameofapis2 V/Zygote﹕ Switching descriptor 9 to /dev/null
01-07 20:16:21.470 11583-11583/com.example.kai.gameofapis2 D/dalvikvm﹕ Late-enabling CheckJNI
01-07 20:16:21.710 11583-11583/com.example.kai.gameofapis2 D/ActivityThread﹕ handleBindApplication:com.example.kai.gameofapis2
01-07 20:16:21.720 11583-11583/com.example.kai.gameofapis2 D/ActivityThread﹕ setTargetHeapUtilization:0.75
01-07 20:16:21.720 11583-11583/com.example.kai.gameofapis2 D/ActivityThread﹕ setTargetHeapMinFree:524288
01-07 20:16:22.301 11583-11583/com.example.kai.gameofapis2 I/MainFragment﹕ Logged in...
01-07 20:16:22.471 11583-11583/com.example.kai.gameofapis2 D/libEGL﹕ loaded /system/lib/egl/libEGL_mali.so
01-07 20:16:22.701 11583-11583/com.example.kai.gameofapis2 D/libEGL﹕ loaded /system/lib/egl/libGLESv1_CM_mali.so
01-07 20:16:22.701 11583-11583/com.example.kai.gameofapis2 D/libEGL﹕ loaded /system/lib/egl/libGLESv2_mali.so
01-07 20:16:22.831 11583-11583/com.example.kai.gameofapis2 D/OpenGLRenderer﹕ Enabling debug mode 0
01-07 20:16:22.831 11583-11583/com.example.kai.gameofapis2 I/MainFragment﹕ Logged in...
01-07 20:16:22.951 11583-11583/com.example.kai.gameofapis2 I/Timeline﹕ Timeline: Activity_idle id: android.os.BinderProxy@41d82b18 time:64292484
01-07 20:16:30.539 11583-11583/com.example.kai.gameofapis2 W/System.err﹕ java.lang.NullPointerException
01-07 20:16:30.549 11583-11583/com.example.kai.gameofapis2 W/System.err﹕ at com.example.kai.gameofapis2.MainFragment$2.onClick(MainFragment.java:75)
01-07 20:16:30.549 11583-11583/com.example.kai.gameofapis2 W/System.err﹕ at android.view.View.performClick(View.java:4438)
01-07 20:16:30.549 11583-11583/com.example.kai.gameofapis2 W/System.err﹕ at android.view.View$PerformClick.run(View.java:18439)
01-07 20:16:30.549 11583-11583/com.example.kai.gameofapis2 W/System.err﹕ at android.os.Handler.handleCallback(Handler.java:733)
01-07 20:16:30.549 11583-11583/com.example.kai.gameofapis2 W/System.err﹕ at android.os.Handler.dispatchMessage(Handler.java:95)
01-07 20:16:30.549 11583-11583/com.example.kai.gameofapis2 W/System.err﹕ at android.os.Looper.loop(Looper.java:136)
01-07 20:16:30.549 11583-11583/com.example.kai.gameofapis2 W/System.err﹕ at android.app.ActivityThread.main(ActivityThread.java:5153)
01-07 20:16:30.549 11583-11583/com.example.kai.gameofapis2 W/System.err﹕ at java.lang.reflect.Method.invokeNative(Native Method)
01-07 20:16:30.549 11583-11583/com.example.kai.gameofapis2 W/System.err﹕ at java.lang.reflect.Method.invoke(Method.java:515)
01-07 20:16:30.549 11583-11583/com.example.kai.gameofapis2 W/System.err﹕ at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:796)
01-07 20:16:30.549 11583-11583/com.example.kai.gameofapis2 W/System.err﹕ at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:612)
01-07 20:16:30.549 11583-11583/com.example.kai.gameofapis2 W/System.err﹕ at dalvik.system.NativeStart.main(Native Method)