发布到 Facebook Graph API 时指定隐私

发布于 2024-09-15 13:09:25 字数 334 浏览 6 评论 0 原文

我想在 Facebook 上自动发布注释,并将其定位到群组中的单个成员。我所说的目标是指只有特定的 Facebook 用户才能阅读该注释。

有没有办法使用图形 API 来做到这一点?我在旧的 REST API 中看到 steam.publish 方法上有一个“隐私”参数(请参阅 http://developers.facebook.com/docs/reference/rest/stream.publish)。图形 API 中有等效的吗?

I want to automatically post Notes on Facebook and have them be targeted to just a single member of a group. By target I mean only a specific Facebook user should be able to read the note.

Is there a way to do this with the graph API? I see in the old REST API there is a "privacy" parameter on the steam.publish method (see http://developers.facebook.com/docs/reference/rest/stream.publish). Is there an equivalent in the graph API?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

醉生梦死 2024-09-22 13:09:25

答案如下。

只需在 JSONObject 格式的 Bundle 中包含“隐私”,包括值“SELF”、“ALL_FRIENDS”或“EVERYONE”。

这是使用android SDK 2.0,现在已经可以使用3.0了,但是使用graph api的方法是一样的,如果遇到任何问题请留下评论:)。

public String PostWall(String Message,int Level){
    /***********************************************************
        * level 0 ==>only me
        * level 1==>friend only
        * level 2==>public
        * level >2 ==>error
    ***********************************************************/
    Bundle params = new Bundle();
    params.putString("message", Message);
    JSONObject privacy = new JSONObject();
    try {
        switch (Level){
            case 0: 
                privacy.put("value", "SELF");
                break;
            case 1: 
                privacy.put("value", "ALL_FRIENDS");
                break;
            case 2: 
                privacy.put("value", "EVERYONE");
                break;
        }
    } catch (JSONException e1) {
    }
    params.putString("privacy", privacy.toString());
    //Step 2 Request
    String resp= "";
    try {
        resp = fb.request("me/feed", params, "POST");
    } catch (FileNotFoundException e) {
    } catch (MalformedURLException e) {
    } catch (IOException e) {
    }
    try{
        resp = new JSONObject(resp).getString("id");
        if(enableLog){
            Log.d(LOGTAG,"*****POSTWALL END*****");
            Log.d(LOGTAG,"RETURN "+resp);
        }
        return resp;
    }catch(JSONException e1){
    }
}
};

Here's the answer.

Just include "privacy" in the Bundle in JSONObject format, including value "SELF", "ALL_FRIENDS" OR "EVERYONE".

This is using android SDK 2.0, and 3.0 is now avaliable, But the way to use graph api is the same, left comment if you reach any problem:).

public String PostWall(String Message,int Level){
    /***********************************************************
        * level 0 ==>only me
        * level 1==>friend only
        * level 2==>public
        * level >2 ==>error
    ***********************************************************/
    Bundle params = new Bundle();
    params.putString("message", Message);
    JSONObject privacy = new JSONObject();
    try {
        switch (Level){
            case 0: 
                privacy.put("value", "SELF");
                break;
            case 1: 
                privacy.put("value", "ALL_FRIENDS");
                break;
            case 2: 
                privacy.put("value", "EVERYONE");
                break;
        }
    } catch (JSONException e1) {
    }
    params.putString("privacy", privacy.toString());
    //Step 2 Request
    String resp= "";
    try {
        resp = fb.request("me/feed", params, "POST");
    } catch (FileNotFoundException e) {
    } catch (MalformedURLException e) {
    } catch (IOException e) {
    }
    try{
        resp = new JSONObject(resp).getString("id");
        if(enableLog){
            Log.d(LOGTAG,"*****POSTWALL END*****");
            Log.d(LOGTAG,"RETURN "+resp);
        }
        return resp;
    }catch(JSONException e1){
    }
}
};
笨死的猪 2024-09-22 13:09:25

您可以使用 SELF

php facebook api 示例:

$privacy = array(
        'value' => 'SELF' //private
    );

$publish = $facebook->post('/me/videos',
        array('access_token' => $page_token,
        'title'=> $title,
        'privacy'=> $privacy,
        'source' => $facebook->videoToUpload($fn),
        'description' => $desc
        ));

包含字段和可选朋友网络,
允许拒绝字段。

value 字段可以指定以下字符串之一:EVERYONE
ALL_FRIENDSNETWORKS_FRIENDSFRIENDS_OF_FRIENDS >自定义 .

如果value设置为CUSTOM<,则必须指定friends字段/code>
包含以下字符串之一:EVERYONENETWORKS_FRIENDS(当
该对象可以被网络和朋友看到),FRIENDS_OF_FRIENDS
ALL_FRIENDSSOME_FRIENDSSELF 或 < strong>NO_FRIENDS(当对象可以
只能通过网络看到)。

networks 字段可能包含以逗号分隔的网络 ID 列表
可以看到该对象,或者 1 表示用户的所有网络。

friends值设置为时,必须指定allow字段
SOME_FRIENDS 并且必须指定以逗号分隔的用户 ID 列表和
“可以”看到该帖子的好友列表 ID。

如果friends字段设置为,则可以指定deny字段
SOME_FRIENDS 并且必须指定以逗号分隔的用户 ID 列表和
“无法”看到该帖子的好友列表 ID。


在以下链接中搜索隐私以查看所有选项:

https://developers.facebook.com/docs/graph-api/reference/v2.6/post

You can use SELF

php facebook api example:

$privacy = array(
        'value' => 'SELF' //private
    );

$publish = $facebook->post('/me/videos',
        array('access_token' => $page_token,
        'title'=> $title,
        'privacy'=> $privacy,
        'source' => $facebook->videoToUpload($fn),
        'description' => $desc
        ));

object containing the value field and optional friends, networks,
allow and deny fields.

The value field may specify one of the following strings: EVERYONE,
ALL_FRIENDS, NETWORKS_FRIENDS, FRIENDS_OF_FRIENDS, CUSTOM .

The friends field must be specified if value is set to CUSTOM and
contain one of the following strings: EVERYONE, NETWORKS_FRIENDS (when
the object can be seen by networks and friends), FRIENDS_OF_FRIENDS,
ALL_FRIENDS, SOME_FRIENDS, SELF, or NO_FRIENDS (when the object can be
seen by a network only).

The networks field may contain a comma-separated list of network IDs
that can see the object, or 1 for all of a user's network.

The allow field must be specified when the friends value is set to
SOME_FRIENDS and must specify a comma-separated list of user IDs and
friend list IDs that 'can' see the post.

The deny field may be specified if the friends field is set to
SOME_FRIENDS and must specify a comma-separated list of user IDs and
friend list IDs that 'cannot' see the post.


Search for privacy on the following link to see all options:

https://developers.facebook.com/docs/graph-api/reference/v2.6/post

不交电费瞎发啥光 2024-09-22 13:09:25

是的,有:

http://developers.facebook.com/docs/reference/api/帖子

有一个名为“隐私”的字段,您可以对其进行修改。

希望有帮助,
-鲁兹贝

Yes, there is:

http://developers.facebook.com/docs/reference/api/post

There's a field called privacy which you can modify.

Hope that helps,
-Roozbeh

清音悠歌 2024-09-22 13:09:25

http://developers.facebook.com/docs/reference/api/post

没有告诉如何指定隐私
以正确的方式

处理各种选项 CUSTOM、FRIENDS、NETWORK_FRIENDS

http://developers.facebook.com/docs/reference/api/post

does not tell how to specify privacy
in correct way

for varied option CUSTOM, FRIENDS, NETWORK_FRIENDS

も星光 2024-09-22 13:09:25

如果您从应用程序发布注释,则可以设置默认活动隐私,如下所示:

在此处输入图像描述

它可能是当您验证自己的应用程序时或在:帐户设置 - > 中设置应用程序。

If you are posting notes from an app, you can set default activity privacy as shown here:

enter image description here

It could be set when you are authenticating your own application, or in: account settings - > applications.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文