如何使用Facebook iOS SDK 3.14.1以编程方式向Facebook测试用户添加测试朋友

问题描述:

我们需要所有测试用户成为彼此的朋友.通过App Dashboard手动执行此操作需要花费大量的工作,具体取决于您需要的测试用户数量(在我们的示例中为50个以上的测试用户).

We need that all our test users to be friends of each other. Doing that through the App Dashboard manually is a tremendous amount of work depending on the number of test users you need (in our case more than 50 test users).

因此,我们正在寻找一种使我们的Facebook测试用户以编程方式彼此成为朋友的方法.我们在以下网站上尝试了这种方法: https://developers.facebook.com/docs/graph-api/reference/v2.0/test-user/friends

Therefore we are looking for a way to make our Facebook test users friends of each other programmatically. We tried this approach following their website here: https://developers.facebook.com/docs/graph-api/reference/v2.0/test-user/friends

问题是,为了从测试用户1向测试用户2发送好友请求,您必须以测试用户1登录,并且为了接受好友请求,您需要以测试用户2登录,与使用App Dashboard-> Roles

The problem is that in order to send a friend request from test user one to test user two you have to be logged in with test user one, and in order to accept the friend request you need to login with test user two, which makes the process even worse than adding manually using the App Dashboard -> Roles

如何使用iOS SDK 3.14.1以编程方式使所有测试用户彼此成为朋友?

How can we make all our test users friend of each other programmatically using iOS SDK 3.14.1?

最简单的方法是使用网络服务器.

It would be easiest to do this with a web server.

例如使用 facebook-node-sdk :

  1. 创建用户 FB.api('/v2.6/{app-id}/accounts/test-users', 'post', { fields: [{ installed: "true", permissions: "user_birthday user_friends email"}] }, function (res) { ... });

  1. Create user FB.api('/v2.6/{app-id}/accounts/test-users', 'post', { fields: [{ installed: "true", permissions: "user_birthday user_friends email"}] }, function (res) { ... });

保存新创建的用户ID和access_token

Save newly created user id and access_token

根据需要重复步骤1-2

Repeat steps 1-2 as desired

从userA向userB发送朋友请求 FB.api('/v2.6/' + userA.fb_id + '/friends/' + userB.fb_id, { access_token: userA.access_token }, 'post', function (res) { ... });

Send friend request from userA to userB FB.api('/v2.6/' + userA.fb_id + '/friends/' + userB.fb_id, { access_token: userA.access_token }, 'post', function (res) { ... });

从userB向userA发送朋友请求以接受 FB.api('/v2.6/' + userB.fb_id + '/friends/' + userA.fb_id, { access_token: userB.access_token }, 'post', function (res) { ... });

Send friend request from userB to userA to accept FB.api('/v2.6/' + userB.fb_id + '/friends/' + userA.fb_id, { access_token: userB.access_token }, 'post', function (res) { ... });

C.f. 连接朋友的边缘