Android Facebook 图形 API
有人有如何使用 Android Graph 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)
Has anyone got an example of how to use the Android Graph API?
I am stuck with the basics, like posting text to the wall on Facebook.
I'm using the Facebook SDK for Android. Here is what I have so far:
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");
Nothing happens, and my Logcat says:
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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
试试这个
你可以通过使用获取访问令牌
try this
you can get access token by using
你可以这样做:--
在捆绑消息中给出描述,如果您想分享服务器上的一些图像,您可以提供链接,如下所示
You can do this like :--
give description in bundle message and if u want to share some image from server u can provide link as i given below