Shajeel Afzal
Shajeel Afzal

Reputation: 5953

"Cannot resolve symbol `Request`" error for facebook Graph API

I include latest facebook SDK 4.0.1into the Android Studio project. I want to do basic Graph API call as listed on Graph API reference

/* make the API call */
new Request(
    session,
    "/me",
    null,
    HttpMethod.GET,
    new Request.Callback() {
        public void onCompleted(Response response) {
            /* handle the result */
        }
    }
).executeAsync();

But i am unable to import Request class, i am getting error Cannot resolve symbolRequest``.

How to resolve this problem? Do i need to import some other library to use Graph API?

Thanks.

Upvotes: 3

Views: 3028

Answers (3)

Abhishek Balani
Abhishek Balani

Reputation: 3803

Other than Request is changed to GraphRequest, Response is changed to GraphResponse and now instead of passing session, pass AccessToken.getCurrentAccessToken or accessToken in the constructor. So your query will be like this:

  GraphRequestAsyncTask graphRequest = new GraphRequest(
                    AccessToken.getCurrentAccessToken(),
                    "/{user-id}/",
                    null,
                    HttpMethod.GET,
                    new GraphRequest.Callback() {
                        public void onCompleted(GraphResponse response) {
        /* handle the result */
                        }
                    }
            ).executeAsync();

Upvotes: 6

Kai
Kai

Reputation: 15476

As @Gokhan explained, the class is called GraphRequest now.

Facebook SDK 4.x is a major update over 3.x with many changes, you should check out Facebook's upgrading guide.

Upvotes: 0

Gokhan Caglar
Gokhan Caglar

Reputation: 1137

The Request class has been renamed to GraphRequest.

Upvotes: 5

Related Questions