-4

我使用 facebook api 将我的 apk 与 facebook 连接起来。我想在我的墙上贴一些文字,但我得到了错误。这是我的帖子类的代码:

public class UiAsyncTask extends AsyncTask<Void, Void, Void> {


        public void onPreExecute() {
            // On first execute
        }

        public Void doInBackground(Void... unused) {

             Log.d("Tests", "Testing graph API wall post");
             try {
                    String response = facebook.request("me");
                    Bundle parameters = new Bundle();
                    parameters.putString("message", "This test message for wall post");
                    parameters.putString("description", "test test test");
                    response = facebook.request("me/feed", parameters, "POST");
                    Log.d("Tests", "got response: " + response);
                    if (response == null || response.equals("") || response.equals("false")) {
                       Log.v("Error", "Blank response");
                    }
             } catch(Exception e) {
                 e.printStackTrace();
             }
            return null;
        }

        public void onPostExecute(Void unused) {
             // Result
        }
    }

这是我在日志中得到的:

got response: {"error":{"message":"An active access token must be used to query information about the current user.","type":"OAuthException","code":2500}} 

我该如何解决我的问题?

4

1 回答 1

0

尝试这个。

public void postToWall(String message) {
    Bundle parameters = new Bundle();
    parameters.putString("message", message);
    parameters.putString("description", "topic share");
    try {
        facebook.request("me");
        String response = facebook.request("me/feed", parameters, "POST");
        Log.d("Tests", "got response: " + response);
        if (response == null || response.equals("") || response.equals("false")) {
            showToast("Blank response.");
        } else {
            showToast("Message posted to your facebook wall!");
        }
    } catch (Exception e) {
        showToast("Failed to post to wall!");
        e.printStackTrace();
    }
}
于 2013-04-29T07:46:19.023 回答