saantiaguilera / android-api-RxFacebook

Reactive Extension for Facebook SDK
Other
19 stars 2 forks source link

Build request with Bundle #6

Closed Savrov closed 7 years ago

Savrov commented 7 years ago

Hello again 🎉 Now i guess, that there is a small bug or i just dont understand how it works. I try to build a query with a Bundle, then pass it to FxFacebook and so on. Like here:

val query = "/SOME_EVENT_ID"
val params = Bundle()
params.putString("fields", "id,name")
params.putString("access_token", "XXXXXXXXXXXXX|YYYYYYYYYYYYYYYY")
val myRequest = GraphRequest(null, query, params, HttpMethod.GET)
RxFacebook.create().request(myRequest).....

And it works. But! If i try to avoid build this String of request & replace it with proper methods (see code below), the app cant get data

val params = Bundle()
params.putString("id", SOME_EVENT_ID)
params.putString("fields", "id,name")
params.putString("access_token", "XXXXXXXXXXXXX|YYYYYYYYYYYYYYYY")
RxFacebook.create().params(params).httpMethod(HttpMethod.GET).request()....

And recieve this pretty message:

responseCode: 200, graphObject: null, error: {HttpStatus: -1, errorCode: -1, errorType: null, errorMessage: java.lang.NullPointerException}}

P.S. For requesting data about events I need token key, but i dont want to force user to auth with facebook. Can i somehow get "default" key?

saantiaguilera commented 7 years ago

The query should be passed as graphPath (see https://github.com/saantiaguilera/android-api-RxFacebook/blob/develop/rx2facebook/src/main/java/com/u/rxfacebook/RxFacebook.kt#L95)

RxFacebook.create()
  .graphPath("/$SOME_EVENT_ID") // Note that the id goes as graphPath. Not in the bundle
  .params(Bundle().apply {
    putString(..., ...) // Add here the fields
    putString(..., ...) // And those stuff
  })
  .get() // This is the same as request() with HttpMethod.GET
  ... // Manage observable

If you dont want to facebook to use the token you have also a skipClientToken(Boolean), this should do what you ask

Savrov commented 7 years ago

Ok, thanks again. P.S. Found out that for events facebook requires access token.