13

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?

2

5 Answers 5

7

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){
    }
}
};
3

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

0

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

1
  • Couldn't understand how to change the privacy ???? the explanation in that page says " any non-default privacy setting must be intentionally chosen by the user. You may not set a custom privacy setting unless the user has proactively specified that they want this non-default setting. "
    – HarshIT
    Commented May 14, 2012 at 10:40
0

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

1
  • you are right, it says about the return type object and all and also mentions below it that we can not change the privacy policy of user.
    – HarshIT
    Commented May 14, 2012 at 10:38
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.