Android Facebook Graph API

知识的领域是无限的,我们的学习也是无限期的。这篇文章主要讲述Android Facebook Graph API相关的知识,希望能为你提供帮助。
有没有人有一个如何使用android Graph API的例子?
我坚持使用基础知识,比如在Facebook上发布文字。
【Android Facebook Graph API】我正在使用面向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)

答案我想你用这个链接http://developers.facebook.com/docs/guides/mobile/#android
另一答案试试这个
Bundle params = new Bundle(); params.putString(Facebook.TOKEN, token); params.putString("message", "graph api"); mAsyncRunner.request("/me/feed", params,"POST", new SampleUploadListener(),null);

您可以使用获取访问令牌
token = mFacebook.getAccessToken();

另一答案你可以这样做: - 在捆绑消息中给出描述,如果你想从服务器分享一些图像,你可以提供我在下面给出的链接
Bundle params = new Bundle(); params.putString("message", "description"); params.putString("link","your image url" ); new GraphRequest( AccessToken.getCurrentAccessToken(), "me/feed", params, HttpMethod.POST, new GraphRequest.Callback() { @Override public void onCompleted(GraphResponse response) { Log.d(TAG, "" + response.toString()); try { JSONObject jsonObject = new JSONObject(response.getRawResponse()); if (jsonObject != null) { String postId = jsonObject.getString("id"); if (postId != null & & !postId.equalsIgnoreCase("")) { hideProgressDialog(); Log.d("postId", "" + postId); } else { hideProgressDialog(); Utils.showToast(getActivity(), getResources().getString(R.string.txt_try_again)); } } else { hideProgressDialog(); Utils.showToast(getActivity(), getResources().getString(R.string.txt_try_again)); }} catch (JSONException e) { hideProgressDialog(); e.printStackTrace(); } catch (Throwable e) { hideProgressDialog(); e.printStackTrace(); }} }).executeAsync();


    推荐阅读