有沒有人有過如何使用Android Graph API的例子?Android Facebook圖形API
我被基礎知識困住了,比如在Facebook上發貼文到牆上。
我正在使用適用於Android的Facebook SDK。以下是我迄今爲止:
Bundle params = new Bundle();
params.putString("message", "picture caption");
AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(facebook);
mAsyncRunner.request("me/feed", params, "POST", new RequestListener() {
@Override
public void onMalformedURLException(MalformedURLException e, Object state) {
// TODO Auto-generated method stub
}
@Override
public void onIOException(IOException e, Object state) {
// TODO Auto-generated method stub
}
@Override
public void onFileNotFoundException(FileNotFoundException e, Object state) {
// TODO Auto-generated method stub
}
@Override
public void onFacebookError(FacebookError e, Object state) {
// TODO Auto-generated method stub
}
@Override
public void onComplete(String response, Object state) {
// TODO Auto-generated method stub
}
}, "foo");
什麼也沒有發生,我的logcat說:
03-02 22:10:02.973: WARN/Bundle(1930): Key message expected byte[] but value was a java.lang.String. The default value <null> was returned.
03-02 22:10:02.983: WARN/Bundle(1930): Attempt to cast generated internal exception:
03-02 22:10:02.983: WARN/Bundle(1930): java.lang.ClassCastException: java.lang.String
03-02 22:10:02.983: WARN/Bundle(1930): at android.os.Bundle.getByteArray(Bundle.java:1305)
03-02 22:10:02.983: WARN/Bundle(1930): at com.facebook.android.Util.encodePostBody(Util.java:63)
03-02 22:10:02.983: WARN/Bundle(1930): at com.facebook.android.Util.openUrl(Util.java:182)
03-02 22:10:02.983: WARN/Bundle(1930): at com.facebook.android.Facebook.request(Facebook.java:559)
03-02 22:10:02.983: WARN/Bundle(1930): at com.facebook.android.AsyncFacebookRunner$2.run(AsyncFacebookRunner.java:253)
給出從你的錯誤消息,它看起來u能提供鏈接就像你正在爲你的參數鍵入一個字符串Bundle當出於某種原因期望的字節數組。由於我沒有實現他們的API,我無法告訴你其他的事情。 – 2011-03-02 21:30:54
是的。我也嘗試了一個字節數組,但它仍然抱怨。我希望有更多關於如何實現這個API的信息。唯一我遇到過的是PHP。 – whirlwin 2011-03-02 21:58:27