Graph API를 사용하는 Facebook 'Friends.getAppUsers'
Friends.getAppUsers
내 애플리케이션을 승인 한 현재 사용자의 친구 목록을 가져 오기 위해 이전 REST API 호출 을 사용하는 애플리케이션이 있습니다.
문서를 읽었습니다. Graph API로 어떻게해야합니까? 이것의 예는 무엇입니까?
나는 잠시 동안 주변을 검색했는데 Graph API를 사용하여 이것이 가능하지 않다고 생각했습니다.
그러나 비슷한 질문을 게시했습니다. 내 애플리케이션을 사용하는 사용자의 친구를보기 위해 이전 GetAppUsers 호출을 대체합니까? , 내가 사용하고 있던 특정 API에 대해 훌륭한 일반적인 답변을 받았습니다.
https://graph.facebook.com/me/friends?fields=installed
또는 더 일반적으로
https://graph.facebook.com/{user id}/friends?fields=installed
그러면 응용 프로그램을 사용하는 친구에 대한 추가 필드 "installed = true"와 함께 모든 친구가 반환됩니다.
다음은 그래프 API 탐색기 에서 작동합니다 .
이것은 FQL로 할 수 있습니다.
SELECT uid FROM user
WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = ?)
AND is_app_user = 1
QED!
예, Graph API는 끔찍하게 문서화되어 있습니다. "application" 유형에 대한 문서가 표시되지 않지만 문서 에서 애플리케이션 정보를 참조합니다.
https://graph.facebook.com/2439131959
그렇다면 Group 구문을 사용하여 애플리케이션의 멤버를 가져올 수 있습니까?
https://graph.facebook.com/2439131959/members
테스트하려면 인증 된 세션이 필요합니다. 그렇지 않으면 Facebook이 FQL을 사용하여 쿼리를 직접 보내도록 강요하는 것처럼 보입니다.
http://developers.facebook.com/docs/reference/fql/application
https://api.facebook.com/method/fql.query?query=QUERY를 가져와 FQL 쿼리를 실행할 수 있습니다 . format 쿼리 매개 변수를 사용하여 응답 형식을 XML 또는 JSON으로 지정할 수 있습니다.
따라서 FQL 쿼리를 전달하여 애플리케이션에 대한 정보를 얻을 수 있습니다.
이전 REST API :
$facebook->api_client->friends_getAppUsers();
새로운 그래프 API :
$facebook->api(array('method' => 'friends.getAppUsers'));
저는이 문제에 대해 많은 조사를했습니다. 내가 알 수 있듯이 Friends.getAppUsers
Graph API를 사용하는 방법은 없습니다 . Facebook에서 제공하는 최신 SDK는 모두 이전 REST API를 사용하여 애플리케이션을 사용하여 친구를 얻습니다.
restFB를 사용 하여 다음을 수행했습니다 (지도에 대해 Igy / Alex에게 감사드립니다). Facebook은 사용자가 설치된 경우 "installed"= true 인 친구 ID 배열을 반환합니다 ( 여기에서 볼 수 있음 ).
먼저 User 클래스를 확장하고 installed
필드를 추가 합니다.
import com.restfb.Facebook;
import com.restfb.types.User;
public class InstalledUser extends User {
@Facebook
private boolean installed;
public InstalledUser() {
}
public boolean getInsatlled() {
return installed;
}
}
다음으로 DefaultFacebookClient를 사용합니다.
FacebookClient facebook = new DefaultFacebookClient(pFacebookAccessToken);
Connection<InstalledUser> installedFacebookUsers = facebook.fetchConnection("/" + pFacebookId + "/friends", InstalledUser.class, Parameter.with("fields", "installed"));
for (List<InstalledUser> friends : installedFacebookUsers) {
for (InstalledUser friend : friends) {
if (friend.getInsatlled()) {
// Add friend.getId() to a list of ID, or whatever
}
}
}
The workaround is to do the filtering yourself. Presumably, you have all the uid's of the users who have signed up for your application sitting in your own database. So first get all the users' friends' uids, and select the users from your database who have matching uids.
The new Facebook Graph API program seems very poorly executed and not quite thought through. It seems they rushed to publish it for Facebook f8 before it was mature, and lots of functionality is missing that was available before.
You can still call the old REST API's in the new Graph API. That is prefectly valid.
An alternative way is to use FQL to get the application user's friends.
I'm not sure if there's a way to do this using just Graph API.
참고URL : https://stackoverflow.com/questions/2785093/facebook-friends-getappusers-using-graph-api
'Programing' 카테고리의 다른 글
Swift를 사용한 하위 클래스 UIApplication (0) | 2020.09.12 |
---|---|
JavaScript로 GetElementById 대신 getElementByClass를 사용하는 방법은 무엇입니까? (0) | 2020.09.12 |
State, ST, IORef 및 MVar의 차이점 (0) | 2020.09.12 |
ARC를 사용하고 iOS 4.0을 대상으로 할 때 약한 참조를 어떻게 대체합니까? (0) | 2020.09.12 |
node.js에서 쉘 명령의 출력을 실행하고 가져옵니다. (0) | 2020.09.12 |