Getting 'unsupported method, fql.multiquery' when fetching data from Facebook - android

I'm trying to fetch data in my Android-App from Facebook via FQL multiquery like discribed here: http://www.kanatorn.info/2011/12/31/fql-multiple-query-android-sdk-example/
here's my code:
Bundle params = new Bundle();
JSONObject multiquery = new JSONObject();
try {
multiquery.put("query1", "SELECT eid, name, start_time, is_date_only, pic_square, pic_big, location FROM event WHERE eid IN" +
"(SELECT eid FROM event_member WHERE uid=me() AND start_time >= now()) ORDER BY start_time");
multiquery.put("query2", "SELECT eid, rsvp_status, start_time FROM event_member WHERE uid=me() AND start_time >= now() ORDER BY start_time");
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
params.putString("method", "fql.multiquery");
params.putString("queries", multiquery.toString());
Session session = Session.getActiveSession();
Request request = new Request(session,
"/fql",
params,
HttpMethod.GET,
new Request.Callback(){
public void onCompleted(Response response) {
...
}
});
Request.executeAndWait(request);
the result I'm getting is the following:
{Response: responseCode: 500, graphObject: null, error: {HttpStatus: 500, errorCode: -1, errorType: Exception, errorMessage: Unsupported method, fql.multiquery}, isFromCache:false}
I can't figure out where my mistake is. It says unsupported method, multiquery, but this actually should be a valid method, right? I looked everywhere for a similiar problem but it seems that I'm alone with that issue.
I have the feeling that I'm missing something simple...
Would be cool if someone can help me out. Thanks!
btw. with normal queries everything works fine.

The linked Kanatorn page says method should be fql.multiquery, but you have just multiquery.

To solve this
have you read this developers page.
http://developers.facebook.com/docs/howtos/androidsdk/3.0/run-fql-queries/
Updated url
https://developers.facebook.com/docs/android/graph/#fql

Related

Facebook Graph request Android name from user ID

I'm trying to get the name of a user from his user ID.
on this link they say that we can do it from a simple HTTP request like that:
http://graph.facebook.com/4
But it seems that this method is outdated because i cant get anything because:
"An access token is requir…o request this resource."
Anyway i tried using their documentation about the graph api on Android and i did it like that:
GraphRequestAsyncTask request1 = new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/"+id1+"/name",
null,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
/* handle the result */
}
}
).executeAsync();
name1.setText(request1.toString());
But on the name1 TextView i get a message that tells me
{RequestAsyncTask:
connection:null,requests:[{Request:
accesToken:{AccessToken
token:ACCESS_TOKEN_REMOVED permissions:
[public_profile]},
graphPath:/100017723671435/name, graphObject: null,
httpMethod:Get,
parameters:Bundle[{}]}]}
I don't really understand how to do, i have a bunch of facebook ID's on my database and i just want to get the name from the ID, to display it on the screen.
The current user of the app is not the profile which i want to get the infos!
EDIT: It seems i misunderstood the /*handle the result*/ commentary, i made this line like that:
name1.setText(response.toString());
But i have still an error on my TextView:
{Response:
responseCode:400,
graphObject:null,
error: { HttpStatus:400,
errorCode: 2500,
errorType: OAuthException,
errorMessage: Unknown path components: /first_name }}
So it seems i don't use the Graph Paths properly. I'm still looking on the doc and on Google, if i find the answer i'll give the code!
Ensure that you are logged in with read permission.
If you are logged in you can try with:
GraphRequest.Callback gCallback = new GraphRequest.Callback() {
#Override
public void onCompleted(GraphResponse response) {
Log.d(TAG, "onCompleted: ");
if (response != null && response.getJSONObject() != null && response.getJSONObject().has("first_name"))
{
try {
name1.setText(response.getJSONObject().getString("first_name"));
} catch (JSONException e) {
Log.e(TAG, "onCompleted: ",e );
}
}
}
};
new GraphRequest(AccessToken.getCurrentAccessToken(),"/me?fields=id,name,gender,email,first_name,last_name", null,HttpMethod.GET, gCallback).executeAsync();
If you have a problem with login, maybe this link can help you.

Can't retrieve friend's album in Android/Facebook

I'm trying to retrieve a friend's albums with the following code. Both the account I'm logged in and the one whose albums I'm trying to get are Test Users, so permissions shouldn't be an issue. I retrieve selectedUsers with a friend picker. But eventually i get this error,
12-18 02:18:32.969: D/error(4182): {HttpStatus: 404, errorCode: 803, errorType: OAuthException, errorMessage: (#803) Some of the aliases you requested do not exist: AaJHRMAiukD_rQWiC-K_RXMEjTWzGjJO-dx6QwonppGEcaNlUL4YKLn80pepf-pXHkrgVNYnPktnH25czlD5eIhkXrtlFN8qQZB1UhhXPEAgAA}
as well as a NullPointerException at getInnerJSONObject line.
String grPath = "/"+selectedUsers.get(0).getId()+"/albums";
RequestAsyncTask req = new Request(Session.getActiveSession(),grPath,null, HttpMethod.GET, new Request.Callback() {
#Override
public void onCompleted(Response response) {
if(null != response.getError()){
Log.d("error", response.getError().toString());
}
GraphObject responseGraphObject = response.getGraphObject();
JSONObject json = responseGraphObject.getInnerJSONObject();
try {
JSONArray jarr = json.getJSONArray("data");
for(int i =0;i<jarr.length();i++){
String name= jarr.getJSONObject(i).getString("name");
String albid= jarr.getJSONObject(i).getString("id");
}
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Did you create your app after 4/30/2014? If so, you're on version 2.x of the Graph API, and you can no longer get the photos of a friend. You can only access the photos of the user who has logged in and authorized your app. This is what #WizKid was referencing.
What you're seeing from selectedUsers.get(0).getID is from the taggable_friends endpoint, which gives you a one-time, obfuscated String id, and you should not try to use it for anything other than to tag friends (like when you're uploading a photo).

how long is the FB postId expiration date?

I write an android application which does a FB like to a FB post.
I succeed in doing it, but after a long time I get this response:
{
Response: responseCode: 400,
graphObject: null,
error:
{
HttpStatus: 400,
errorCode: 100,
errorType: OAuthException,
errorMessage: (#100) Error finding the requested story
},
isFromCache:false
}
for the code:
Request request = new Request(
session,
takeFromPublicMacrosOrServer(currentOffer.postId)
+ "/likes", null, HttpMethod.POST,
new Request.Callback() {
#Override
public void onCompleted(Response response) {
// Request complete
if (response.getError() == null) {
UnlockRequestToServer unlockRequestToServer = new UnlockRequestToServer(
mOffersListActivity,
PublicMacros.TYPE_UNLOCK_FB_LIKE,
currentOffer.postId);
} else {
final String errorMsg = "error: "
+ response.getError()
.toString();
Log.e(MyLogger.TAG, errorMsg);
if (BaseApplication
.getCurrentActivity() != null) {
BaseApplication
.getCurrentActivity()
.runOnUiThread(
new Runnable() {
public void run() {
if (PublicMacros.DEBUG) {
Toast.makeText(
BaseApplication
.getCurrentActivity(),
errorMsg,
Toast.LENGTH_LONG)
.show();
}
}
});
}
}
String re = response.toString();
}
});
request.executeAsync();
Does someone know how long is postId valid for FB like action ?
How do I get a page Access Token that does not expire? May contain some useful iformaion for you.
Facebook 3.0 How to post wall? Shows you how to post to your wall
This Question shows you the 'like' Facebook like in android using android.
EDIT
Facebook doesn't notify you that a previously issued access token has
become invalid. Unless you have persisted the expiry time passed to
your App along with the access token, your app may only learn that a
given token has become invalid is when you attempt to make a request
to the API. Also, in response to certain events that are
security-related, access tokens may be invalidated before the expected
expiration time.

Cannot read a facebook event with graph API from android app

I ma trying to read facebook event's details from an ANdroid application by using this code :
new Request(
session,
"me/events/created",
null,
HttpMethod.GET,
new Request.Callback() {
public void onCompleted(Response response) {
System.out.println("Result: " + response.toString());
}
}
).executeAsync();
but I m always receiving a ampty response :
Result: {Response: responseCode: 200, graphObject: GraphObject{graphObjectClass=GraphObject, state={"data":[]}}, error: null, isFromCache:false}
Although when i tried the Graph API Explorer https://developers.facebook.com/tools/explorer i get the right list !!!!
Have you configured the correct permissions for your app? To get the User's Events, you need to aquire the user_events permission upon login.
See https://developers.facebook.com/docs/graph-api/reference/v2.0/user/events/#readperms

Posting image on friends wall using fb android sdk 3.0

i m trying to post images on friends fb wall, im getting selected friend ID,
and image that is converted in base64 string
just getting response as error below
{Response: responseCode: 200, graphObject: null, error: {HttpStatus: 200, errorCode: 3, errorType: null, errorMessage: Unknown method}, isFromCache:false}
my code below
if (hasPublishPermission()) {
Request postToWall = new Request();
for (GraphUser friend : selectedFriends) {
Constants.showLog("Selected Frnd", friend.getId());
Constants.showLog("Selected Pic", picture);
Bundle parameters = new Bundle();
parameters.putByteArray("message", "Greetings from Wish Well!".getBytes());
parameters.putByteArray("link", "http://pictwist.cloudganga.com".getBytes());
parameters.putByteArray("picture", picture.getBytes());
parameters.putByteArray("target_id", friend.getId().getBytes());
postToWall = Request.newRestRequest(Session.getActiveSession(), friend.getId() + "/feed", parameters, HttpMethod.POST);
Constants.showToast(getApplicationContext(), "Posted image on friend wall");
}
postToWall.setCallback( new Request.Callback()
{
#Override
public void onCompleted(Response response)
{
Constants.showLog("Responce Posting image", response.toString());
}
});
Request.executeBatchAsync(postToWall);
}
please help
Posting image or any content on friend's walls is no more supported by the sdk since feb 6, 2013. You need to use the feed dialog to do that..
check this link..
https://developers.facebook.com/roadmap/completed-changes/

Categories

Resources