Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to change privacy settings for photos posted on facebook via graph API

When publishing a post on the user's wall (via the graph API) I know how to change the privacy settings using the "privacy" field, and it works fine.

However, how do I do the same on a photo published into an album? Photos in albums also have privacy settings (you can set them manually so I guess you can set them via the API, or can't you?). The privacy field for the Photo object does not exist. I thought it may be undocumented so I tried it, but it doesn't work.

So how do I change the privacy settings for a photo? (ideally at the very moment of publishing it)

thanks m.

like image 507
matteo Avatar asked Jan 26 '26 18:01

matteo


1 Answers

From what I've seen you can't set a Photo's privacy directly when publishing (the API seems to only take "source" and "message" values).

However, if you create a new Album and pass in "visible" with a value of "everyone" then the album is "public".

    <form action="https://graph.facebook.com/me/albums?access_token=<?= $fb_access_token ?>" method="POST">
        Album name
        <input name="name" type="text" value="Name of Album"><br/><br/>
        Album message
        <input name="message" type="text" value="Message on Album"><br/><br/>
        Album visible level
        <input name="visible" value="everyone" /><br/><br/>
        <input type="submit" value="Create"/>
    </form>

If you then upload a Photo into that album then the Photo will also be "public".

    <form enctype="multipart/form-data" action="https://graph.facebook.com/[ALBUM_ID]/photos?access_token=<?= $fb_access_token ?>" method="POST">
        Please choose a photo
        <input name="source" type="file"><br/><br/>
        Say something about this photo:
        <input name="message" type="text" value=""><br/><br/>
        <input type="submit" value="Upload"/>
    </form>

To my knowledge the "visible" setting is undocumented... I found it in the FQL table: http://developers.facebook.com/docs/reference/fql/album/

You would think it accepted "privacy" but in my experience it does not. http://developers.facebook.com/docs/reference/api/album/

like image 82
Chris Jacob Avatar answered Jan 29 '26 10:01

Chris Jacob



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!