gpt4 book ai didi

java - Android Facebook 图谱 API

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:54:13 25 4
gpt4 key购买 nike

有人有关于如何使用 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)

最佳答案

试试这个

Bundle params = new Bundle();
params.putString(Facebook.TOKEN, token);
params.putString("message", "graph api");
mAsyncRunner.request("/me/feed", params,"POST", new SampleUploadListener(),null);

你可以通过使用获取访问 token

      token = mFacebook.getAccessToken();

关于java - Android Facebook 图谱 API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5173552/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com