"Unable to resolve" Request "symbol error for facebook charts API.

I am including the latest facebook SDK file in my 4.0.1

Android Studio project. I want to make a basic Graph API call given in the 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 can't import the class Request

, I get Cannot resolve symbol

Request error .

How to solve this problem? Do I need to import any other library to use the Graph API?

Thank.

+3


source to share


3 answers


The Request class has been renamed to GraphRequest.



+5


source


Instead of Request

changed to GraphRequest

, Response

changed to, GraphResponse

and now instead of passing session

, pass AccessToken.getCurrentAccessToken or accessToken

in the constructor. So your request will look 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();

      

+6


source


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

The Facebook SDK 4.x is a major update over 3.x with many changes, you should check the Facebook update guide .

0


source







All Articles