I've been searching over the developers.facebook website looking for a way to use the new SDK and send FQL queries but it seems like everything has changed and the documentation is talking about all sorts of other ways to request me
or friends
but not specific information such as are those friends using my app or not?
so I wrote down a nice FQL query
select uid, name, pic_square, is_app_user from user where uid in (select uid2 from friend where uid1 = me())
and now, all I have to do is run it.
Since the only requests that seem good for returning a list of friends are Request.executeMyFriendsRequestAsync
and Request.newMyFriendsRequest
I assumed they'ed be my friends, but both don't allow the fine tuning of a FQL query.
how can I send a query and get back a list of friends or at least a JSONArray
?
the Hackbook - FQL Query tutorial is using the old version of the SDK and I don't know what to do.
UPDATE:
I added these lines of code thinking it will let me create this query:
public void onCreate(Bundle savedInstanceState) {
// SOME CODE
this.openSession();
}
protected void onSessionStateChange(SessionState state, Exception exception) {
if (state.isOpened()) {
Session activeSession = getSession().getActiveSession();
facebook.setAccessToken(activeSession.getAccessToken());
facebook.setAccessExpires(activeSession.getExpirationDate().getTime());
Request req = Request.newMyFriendsRequest(activeSession, new GraphUserListCallback() {
@Override
public void onCompleted(List<GraphUser> users, Response response) {
System.out.println(response.toString());
}
});
Bundle params = new Bundle();
params.putString("method", "fql.query");
params.putString("query", "select uid, name, pic_square, is_app_user " + "from user where uid in "
+ "(select uid2 from friend where uid1 = me())");
req.setParameters(params);
Request.executeBatchAsync(req);
}
}
I did this, thinking it will edit the request and add the information I want but I got this error:
10-31 09:36:31.647: E/AndroidRuntime(15986): java.lang.NullPointerException
10-31 09:36:31.647: E/AndroidRuntime(15986): at com.sample.facebook.to.db.MainActivity$1.onCompleted(MainActivity.java:62)
10-31 09:36:31.647: E/AndroidRuntime(15986): at com.facebook.Request$2.onCompleted(Request.java:269)
10-31 09:36:31.647: E/AndroidRuntime(15986): at com.facebook.Request$4.run(Request.java:1197)
10-31 09:36:31.647: E/AndroidRuntime(15986): at android.os.Handler.handleCallback(Handler.java:587)
10-31 09:36:31.647: E/AndroidRuntime(15986): at android.os.Handler.dispatchMessage(Handler.java:92)
10-31 09:36:31.647: E/AndroidRuntime(15986): at android.os.Looper.loop(Looper.java:130)
10-31 09:36:31.647: E/AndroidRuntime(15986): at android.app.ActivityThread.main(ActivityThread.java:3691)
10-31 09:36:31.647: E/AndroidRuntime(15986): at java.lang.reflect.Method.invokeNative(Native Method)
10-31 09:36:31.647: E/AndroidRuntime(15986): at java.lang.reflect.Method.invoke(Method.java:507)
10-31 09:36:31.647: E/AndroidRuntime(15986): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
10-31 09:36:31.647: E/AndroidRuntime(15986): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665)
10-31 09:36:31.647: E/AndroidRuntime(15986): at dalvik.system.NativeStart.main(Native Method)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…