Error on post message to the facebook wall in android 4.0.3

血红的双手。 提交于 2019-12-12 15:24:07

问题


I try to post message on user facebook wall. It's work on previous platform versions, but on Android 4.0.3 I have error:

    07-19 14:53:02.945: W/System.err(29740): java.net.UnknownHostException: Unable to resolve host "graph.facebook.com": No address associated with hostname
07-19 14:53:02.965: W/System.err(29740):    at java.net.InetAddress.lookupHostByName(InetAddress.java:436)
07-19 14:53:02.965: W/System.err(29740):    at java.net.InetAddress.getAllByNameImpl(InetAddress.java:245)
07-19 14:53:02.965: W/System.err(29740):    at java.net.InetAddress.getAllByName(InetAddress.java:220)
07-19 14:53:02.965: W/System.err(29740):    at libcore.net.http.HttpConnection.<init>(HttpConnection.java:71)
07-19 14:53:02.965: W/System.err(29740):    at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50)
07-19 14:53:02.965: W/System.err(29740):    at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:351)
07-19 14:53:02.965: W/System.err(29740):    at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:86)
07-19 14:53:02.965: W/System.err(29740):    at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
07-19 14:53:02.965: W/System.err(29740):    at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:308)
07-19 14:53:02.965: W/System.err(29740):    at libcore.net.http.HttpsURLConnectionImpl$HttpsEngine.makeSslConnection(HttpsURLConnectionImpl.java:460)
07-19 14:53:02.965: W/System.err(29740):    at libcore.net.http.HttpsURLConnectionImpl$HttpsEngine.connect(HttpsURLConnectionImpl.java:441)
07-19 14:53:02.965: W/System.err(29740):    at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:282)
07-19 14:53:02.965: W/System.err(29740):    at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:232)
07-19 14:53:02.975: W/System.err(29740):    at libcore.net.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:80)
07-19 14:53:02.975: W/System.err(29740):    at libcore.net.http.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:164)
07-19 14:53:02.975: W/System.err(29740):    at com.facebook.android.Util.openUrl(Util.java:193)
07-19 14:53:02.975: W/System.err(29740):    at com.facebook.android.Facebook.request(Facebook.java:751)
07-19 14:53:02.975: W/System.err(29740):    at com.koloneme.socialnetworking.FacebookUtility.postOnWall(FacebookUtility.java:115)
07-19 14:53:02.975: W/System.err(29740):    at com.koloneme.socialnetworking.FacebookUtility.facebookAuthorization(FacebookUtility.java:65)
07-19 14:53:02.975: W/System.err(29740):    at com.koloneme.socialnetworking.FacebookActivity.onCreate(FacebookActivity.java:33)
07-19 14:53:02.975: W/System.err(29740):    at android.app.Activity.performCreate(Activity.java:4538)
07-19 14:53:02.975: W/System.err(29740):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1071)
07-19 14:53:02.975: W/System.err(29740):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2158)
07-19 14:53:02.975: W/System.err(29740):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2237)
07-19 14:53:02.975: W/System.err(29740):    at android.app.ActivityThread.access$600(ActivityThread.java:139)
07-19 14:53:02.975: W/System.err(29740):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1262)
07-19 14:53:02.975: W/System.err(29740):    at android.os.Handler.dispatchMessage(Handler.java:99)
07-19 14:53:02.975: W/System.err(29740):    at android.os.Looper.loop(Looper.java:154)
07-19 14:53:02.975: W/System.err(29740):    at android.app.ActivityThread.main(ActivityThread.java:4974)
07-19 14:53:02.975: W/System.err(29740):    at java.lang.reflect.Method.invokeNative(Native Method)
07-19 14:53:02.975: W/System.err(29740):    at java.lang.reflect.Method.invoke(Method.java:511)
07-19 14:53:02.975: W/System.err(29740):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
07-19 14:53:02.975: W/System.err(29740):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
07-19 14:53:02.975: W/System.err(29740):    at dalvik.system.NativeStart.main(Native Method)
07-19 14:53:02.975: W/System.err(29740): Caused by: libcore.io.GaiException: getaddrinfo failed: EAI_NODATA (No address associated with hostname)
07-19 14:53:02.975: W/System.err(29740):    at libcore.io.Posix.getaddrinfo(Native Method)
07-19 14:53:02.975: W/System.err(29740):    at libcore.io.ForwardingOs.getaddrinfo(ForwardingOs.java:55)
07-19 14:53:02.975: W/System.err(29740):    at java.net.InetAddress.lookupHostByName(InetAddress.java:421)
07-19 14:53:02.975: W/System.err(29740):    ... 33 more
07-19 14:53:03.075: W/webcore(29740): java.lang.Throwable: EventHub.removeMessages(int what = 105) is not supported before the WebViewCore is set up.
07-19 14:53:03.075: W/webcore(29740):   at android.webkit.WebViewCore$EventHub.removeMessages(WebViewCore.java:1889)
07-19 14:53:03.075: W/webcore(29740):   at android.webkit.WebViewCore$EventHub.access$8500(WebViewCore.java:973)
07-19 14:53:03.075: W/webcore(29740):   at android.webkit.WebViewCore.removeMessages(WebViewCore.java:2088)
07-19 14:53:03.075: W/webcore(29740):   at android.webkit.WebView.sendViewSizeZoom(WebView.java:3450)
07-19 14:53:03.075: W/webcore(29740):   at android.webkit.ZoomManager.setZoomScale(ZoomManager.java:679)
07-19 14:53:03.075: W/webcore(29740):   at android.webkit.ZoomManager.access$1900(ZoomManager.java:59)
07-19 14:53:03.075: W/webcore(29740):   at android.webkit.ZoomManager$PostScale.run(ZoomManager.java:1174)
07-19 14:53:03.075: W/webcore(29740):   at android.os.Handler.handleCallback(Handler.java:607)
07-19 14:53:03.075: W/webcore(29740):   at android.os.Handler.dispatchMessage(Handler.java:92)
07-19 14:53:03.075: W/webcore(29740):   at android.os.Looper.loop(Looper.java:154)
07-19 14:53:03.075: W/webcore(29740):   at android.app.ActivityThread.main(ActivityThread.java:4974)
07-19 14:53:03.075: W/webcore(29740):   at java.lang.reflect.Method.invokeNative(Native Method)
07-19 14:53:03.075: W/webcore(29740):   at java.lang.reflect.Method.invoke(Method.java:511)
07-19 14:53:03.075: W/webcore(29740):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
07-19 14:53:03.075: W/webcore(29740):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
07-19 14:53:03.075: W/webcore(29740):   at dalvik.system.NativeStart.main(Native Method)

I'm using this facebook sdk -https://github.com/facebook/facebook-android-sdk/

Here is my code to posting message on wall:

 private static void postOnWall(String msg) {
            Log.d(LOGTAG, "Testing graph API wall post");
             try {
                 //   String response = facebook.request("me");
                    Bundle parameters = new Bundle();
                    parameters.putString("message", msg);
                    parameters.putString("description", "test test test");
                    String response = facebook.request("me/feed", parameters, 
                            "POST");
                    Log.d(LOGTAG, "got response: " + response);
                    if (response == null || response.equals("") || 
                            response.equals("false")) {
                       Log.v(LOGTAG, " error Blank response");
                    }
             } catch(Exception e) {
                 e.printStackTrace();
             }
        }

回答1:


There are three reasons that you would get this exception:

  1. You have not declared the internet permission in your manifest
  2. The device does not have an internet connection, or has one which blocks facebook access at the DNS level. Try using a home network if you're behind a company porxy.
  3. Facebook's server's are temporarily not working.



回答2:


i get

got response: {"error":{"message":"An active access token must be used to query information about the current user.","type":"OAuthException","code":2500}}



来源:https://stackoverflow.com/questions/11560444/error-on-post-message-to-the-facebook-wall-in-android-4-0-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!