使用方法如下
/* make the API call */
new Request(
session,
"/me/invitable_friends",
null,
HttpMethod.GET,
new Request.Callback() {
public void onCompleted(Response response) {
/* handle the result */
}
}
).executeAsync();
接著將會回傳如下的資料 {
"id": "AVlzYTkXshfBqLe58zR9tY5dZ7L0wltTUkWKT0Z5V87zkwv-39...",
"name": "Guy Cross",
"picture": {
"data": {
"is_silhouette": false,
"url": "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-prn1/t5.0-1/623782_622770420_2109148508_q.jpg"
}
}
}
可以發現,我們再也無法取得使用者真實的fbId,相對的我們只能取得 friend Token,接著就可以使用Request Dialog 發送訊息,然後在to 的param中填入 friend Token即可
Bundle params = new Bundle();
params.putString("message", "Take this bomb to blast your way to victory!");
// Optionally provide a 'to' param to direct the request at a specific user
params.putString("to", "RECIPIENT_USER_ID");
// Give the structured request information
params.putString("action_type", "send");
params.putString("object_id", "YOUR_OBJECT_ID");
WebDialog requestsDialog = (
new WebDialog.RequestsDialogBuilder(getActivity(),
Session.getActiveSession(),
params))
.build();
requestsDialog.show();
在發送成功之後可以得到一組
Parameter | Description |
---|---|
request | The request object ID. To get the full request ID, concatenate this with a user ID from the to field: <request_object_id>_<user_id> |
to | An array of the recipient user IDs for the request that was created. |
接著將 requestId and UserId 組起來,就可以得到完整的資料
http://graph.facebook.com/<REQUEST_OBJECT_ID>_<USER_ID>?access_token=APP_ACCESS_TOKEN
在這邊可以得到朋友 app scope Id。{
"id": "REQUEST_OBJECT_ID",
"application": {
"name": "APP_DISPLAY_NAME",
"namespace": "APP_NAMESPACE",
"id": "APP_ID"
},
"to": {
"name": "RECIPIENT_FULL_NAME",
"id": "RECIPIENT_USER_ID"
},
"from": {
"name": "SENDER_FULL_NAME",
"id": "SENDER_USER_ID"
},
"message": "ATTACHED_MESSAGE",
"created_time": "2014-01-17T16:39:00+0000"
}
目前好像還找不到較好的方法取得friends list , 或許過陣子facebook會提供相關的api
不太懂@@ 所以現在只能用這個抓到好友資料嗎
回覆刪除能直接用android 抓taggable_friends的資料列在手機上嗎
是的,在3.14之後friend api不會再回傳好友列表,你也可以使用taggable_friends不過那個api似乎要送審才能使用
刪除恩@@我大概懂了 爬了文章 請問 Android 要如何結合 Graph API 去找好友還是不懂qq
回覆刪除目前並沒有辦法利用graphapi去取得好友名單,目前只有兩條路invitable friend 和 taggable friend 目前只有這兩個api可以取得好友相關資訊,或許之後會有其他的api可以使用吧
回覆刪除想請問一下如何取得大張的圖片?
回覆刪除是過了幾次,在Graph API取得皆沒問題,但在Android 不知如何輸入條件為picture.type(large)
你可以試試看這個方法
刪除https://graph.facebook.com/{UserId}/picture?type=square&height=100&width=100