3

我尝试在用户 facebook 墙上发布消息。它适用于以前的平台版本,但在 Android 4.0.3 上我有错误:

    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)

我正在使用这个 facebook sdk - https://github.com/facebook/facebook-android-sdk/

这是我在墙上发布消息的代码:

 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();
             }
        }
4

2 回答 2

9

出现此异常的原因有以下三个:

  1. 您尚未在清单中声明互联网权限
  2. 该设备没有互联网连接,或者有一个在 DNS 级别阻止 facebook 访问的设备。如果您使用公司代理,请尝试使用家庭网络。
  3. Facebook 的服务器暂时无法工作。
于 2012-07-19T12:07:10.467 回答
0

我明白了

得到响应:{“错误”:{“消息”:“必须使用活动访问令牌来查询有关当前用户的信息。”,“类型”:“OAuthException”,“代码”:2500}}

于 2012-07-31T16:23:52.110 回答