How to programmatically change Facebook posts visibility to "public" on iOS - ios

Would like to change the default visibility of app and posts in Facebook from "Friends" to "Public" programmatically on iOS. Is there any example code for this? Thanks a lot in advance.

You can set defaultAudience Property .
Most applications use FBSessionDefaultAudienceNone here, only specifying an audience when using reauthorize to request publish permissions.
There are other option to set is,
FBSessionDefaultAudienceNone:
No audience needed; this value is useful for cases where data will only be read from Facebook.
FBSessionDefaultAudienceOnlyMe:
Indicates that only the user is able to see posts made by the application.
FBSessionDefaultAudienceFriends:
Indicates that the user's friends are able to see posts made by the application.
FBSessionDefaultAudienceEveryone:
Indicates that all Facebook users are able to see posts made by the application.

It appears from here and here that you can setup the privacy of the post at creation time, but you cannot edit it.
Also, per facebook's developer TOS and Privacy Policy, unless what you are doing [changing the default privacy of a post] is specifically authorized each time by the user, it'd be breaking terms of service and immediately get your app shut down. Facebook takes privacy very, very seriously.

Related

Is there a way to know if there is a cookie available before showing the SFAuthenticationSession prompt

On iOS 11, Apple introduced a new way to share auth data between the web and a Mobile App with SFAuthenticationSession.
It would be a bad user experience to show the SFAuthenticationSession prompt to every new users - that might have never used my website - to have them agree and then get nothing out of it and have ask them to login.
The documentation is pretty empty on Apple side. This is the only example I found.
Is there a way to know if there is a cookie available before showing the SFAuthenticationSession prompt? Or maybe, with the Associated Domains enabled, when authenticating with my domain, the system should not show the prompt?
No. Even if there aren't cookies, the user can login entering his username/password and then clicking on "Login"/"Enter" on the website (E.g: Facebook, Instagram).
Accessing the cookies won't be enabled:
When the webpage is presented, it runs in a separate process, so the user and web service are guaranteed that the app has no way to gain access to the user’s credentials. Instead, the app gets a unique authentication token.
Official docs
Working example for Instagram-OAuth: https://github.com/dvdhpkns/SFAuthenticationSession-Instagram-Oauth
And the GitHub repo you added was posted by the author to send a bug report about errors in cookie sharing for local servers (rdar://33418129. Original tweet)
Are cookies shared between Safari and SFAuthenticationSession?
#DVDHPKNS
They’re supposed to be shared, but we have some timing bugs right now. Please do file bugs about what you’re seeing.
#rmondello (Apple employee)
P.S: They added more information to the docs since your original post date.

Alternative to Facebook read_stream

Is there an alternative to allowing the permissions of some sort rather then 'read_stream' permission in Facebook, for a user to read or an app pull their Facebook feed or home feed?
It's very hard, if at all, for Facebook to approve the 'read_stream' permission, so I'm looking for an alternative steps to still allow for our users to pull their favorite stories in our rails app. Any suggestions?
There is no alternative. You can use user_status to get the status posts of the authorized user with /me/statuses.
Btw, it´s not only "hard" to get read_stream approved, it´s nearly impossible ;) - but for very good reasons. Apps should not get access to posts of users who did not even authorize the App.
edit: There is also user_posts now, as replacement for read_stream: https://developers.facebook.com/docs/apps/changelog#v2_3_new_features
Did some investigation. And it is possible.
Instead of the feed you need to access the endpoint /me/posts
This API is accessible with either read_stream or user_posts permission.
https://developers.facebook.com/docs/facebook-login/permissions/v2.3#reference-user_posts
See here for more information:
https://developers.facebook.com/docs/graph-api/reference/v2.3/user/feed
It is quite hidden, but if you know where to look you can find the docs.

Facebook app permissions

I have an iOS app which posts to Facebook on behalf of the user logged in through the iOS Facebook setting.
Two problems -
the posts are marked private, the users friends don't see them.
The iOS app want to be able to harvest Like and Comment info but I get back a 400 from FB.
Here's the wrinkle, my Facebook account works perfectly (posts are visible to friends and I can get the Like and Comment info), but a test user account will post only as private and the iOS app gets a 400 when trying to get post info.
The attached screen shots show the different permissions (top for tester, bottom for me) but I can figure out what to ask Facebook for at login to get the same permissions for both users. Currently I'm asking for publish_actions and user_status.
Any help would be much appreciated!
You need to make sure you are asking for public_profile also you need to make sure you split your permission access into two pieces, as per FB, 1) read 2) write
Just follow the login process on the Facebook Dev page, this will allow you to outline your permissions the right way. Also make sure your test user is added into the groups on your Facebook Dev portal.
Also can you provide any code of what you have tried?
Turns out the post_id element was not what I wanted but rather the id. After that I could use json to get the comments and likes. So the call was almost correct.
And adding stream_read to the permissions got the post to be visible to friends...
Thanks for all the help!

Parse and Additional Facebook Permissions (iOS)

There are two Parse methods for reauthorizing a Facebook User (to gain additional permissions) in Parse (for iOS):
reauthorizeUser:withPublishPermissions:audience:block:
reauthorizeUser:withPublishPermissions:audience:target:selector:
Unfortunately, both of these methods are for publishPermissions. I am confused, because it seems that there is no way to add additional read permissions (i.e. Extended Profile Permissions) after the initial login.
Facebook advises that, when doing a general login (i.e. on app opening), you only ask for basic permissions, and then ask for extended permissions as needed, so as not to scare off the user.
So with Parse and Facebook for iOS, does this now mean that we need to ask for every single read permission that we may possibly need at initial login?
Overall it seems that the Parse documentation and framework seems to be lacking a lot of the Facebook instructions for login in various scenarios. We are directed to view the Facebook SDK, but everything there seems to apply to FBSession, and it is not clear which methods are replaced by Parse and which are needed in addition to Parse.
I, for example, have an app where the user can login to Parse via FB on app launch, but does not have to. If they do login, they are asked for only the basic permissions, as advised by FB. Then, should the user try to perform certain actions, they are asked for the permissions for that particular action. I have additional read permissions that need to be granted for the extended profile, as well as publish_actions.
Can anyone give me some direction in this case, or point me too a really thorough, up-to-date, example? The Parse FB Scrumptious example code looked promising to me at first, but it is severely outdated.
Thanks!
Apparently there are more than one way to do it. The easiest one I found using Parse for Android was like this:
Collection<String> publishPermissions = Arrays.asList("publish_actions");
ParseFacebookUtils.linkWithPublishPermissionsInBackground(user, myActivityOrFragment, publishPermissions, new SaveCallback() {...});
Which means that after logging in, you should call linkWithPublishPermissionsInBackground with your user reference and the new permission list. It will open a new Facebook window asking for that permission and link the result to your user.
This code I tested and it works. But seems that Parse is not that smart, some things it does automatically and some it does not. So after that you need to call something like:
ParseFacebookUtilities.linkInBackground(ParseUser, AccessToken)
To actually save it to the user on the server, otherwise, it would work only while the App is running.

How to make posts from like button public by default?

I have an unusual problem with my website, which has been built using Ruby on Rails technology. Whenever I click "Like" button under any post on my webpage, the post is supposed to be shared on my facebook profile like posts from 9gag. The problem is that by default, this post's visibility on my facebook profile is set that only I can see it and I want the post to be (by default) visible for all my friends. How can I do that? I couldn't find anything helpful on google about this case.
Thanks for help in advance!
I had the same problem with my website. For some reason, the Facebook App that you create to add widgets to your website sets its privacy default in your profile to "only me".
This only happens for the user that creates the App (maybe to avoid making your first tests and debug public) : in fact, I noticed that other users can share articles publicly without changing any settings.
To change it, just go to privacy settings in your Facebook profile: there you will see your website preference under Applications. Change it from "Only me" to "friends" or "public"

Resources