Programing

Graph API를 사용하는 Facebook 'Friends.getAppUsers'

crosscheck 2020. 9. 12. 09:08
반응형

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.getAppUsersGraph 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

반응형