Facebook Like button for one facebook page of an app from it's own ios app - facebook

I am looking for Like Button to be shown in my ios native app, users of that app have already connected to app via facebook account.
there are several questions related to Facebook Like Button on stackoverflow but those are not specific to authorized single facebook page of the app.
According to official doc of facebook, facebook pages can not be liked via built-in action o open graph api.
But want only one official facebook page of that app to be liked by user when he hits like button. i don't want user to navigate away from the app or login again in web view to like facebook page.
is it possible to like app's facebook page without promoting user to log in again in webveiw?
Edit
Findings
1. https://stackoverflow.com/a/5837036/1632984
2. Comment by wallacer
"the general consensus does seem to be that you can't like a page on behalf of the user, however I just had an ios game like a page on my behalf. Extreme Road Trip successfully manages to get you to like their own page. I wish I'd paid more attention when I did it now..." – wallacer

This still can't be done directly using the graph api ( to the best of my knowledge ). What you can do is open a webview to the page you want the user to like. If you're rewarding their liking your app or something, when they close the webview (you'll have to provide a close button), you can use the graph api to check whether they like your app page. As far as I can tell this is the best current solution - and seems to be the approach taken by mobile games.
That said, I haven't used Facebook SDK 3 yet, so there may be something in there that could help you.

It appears that Liking a page on behalf of a user is still impossible. I've glanced over the iOS SDK Reference, and it doesn't seem like there is a built in mechanism to like anything.
However, in reading one of the other posts you linked to, and remembering that Facebook opened up the Like open graph action so app developers could allow their users to like content generated by their application...I found this link about built-in-actions (likes).
According to that link, you can post Like actions to your users by POSTing to https://graph.facebook.com/<user_id>/og.likes with the POST params for object (the open graph object URL you want to like on behalf of the user in this case your page's url. eg. www.facebook.com/yourpage) and access_token (obviously, for your user).
I'm not totally convinced that will work; though it is conceivable. My second thought would be to create an Open Graph Object for your page, and have all your users like that. Though, that is a little less ideal, as it removes the possibility of people finding your Page while they're on Facebook and would require you to put a lot more effort into getting likes for the Page via your website, application, etc.
I hope that helps a bit, good luck.

Related

If Facebook Feed dialog is deprecated, how are you to share posts on Facebook?

I have been working on a Facebook app for some time, and we are having trouble getting the app approved. I feel like Facebook's app approval process is a constantly moving target and their explanations are provide the least amount of detail possible, leaving the door open for further rejections.
We are using a Facebook app to provide sharing functionality for products that are behind a paywall. All of our share buttons are custom, so they fit in our designs (we don't want to use the out of the box buttons). We first built the app attempting to use the recommended share dialog with open graph actions and stories. The problem here is that you can only use the share dialog with a shared link. Facebook reads any open graph tags on the page to provide sharing information, but because there are many different "products" on a given page, we can't use open graph tags. Because of our environment, we couldn't use the actions or stories. Furthermore, we'd like to customize that share information, so using share dialog is not an option.
Unfortunately, we had left our open graph stories and actions in our app when we first attempted approval. In our first denial, Facebook told us that we had implemented our open graph actions and stories incorrectly. We were not using the share dialog, but the 'feed' method, which is deprecated in 2.0 but still works. Thinking that Facebook looked at our app and noticed we were not using those actions correctly, we figured if we removed those stories and actions from the app, Facebook would see our share method worked and approve us. Wrong.
We had built the share using the publish_actions permission, along with FB.login() and FB.ui(). Facebook denied us because our app did not need publish_actions. They recommended we use the share dialog which did not need login or permissions.
We removed the publish_actions permission and FB.login(). When we tested this, you could still login to Facebook and perform the share WITHOUT fb.login(). So we thought it was good to go. It was not; Facebook told us we needed to implement login(), even thought the docs say you don't need it.
Now we have reimplemented login() and are going to try to get it approved again, but I have a feeling it's going to get rejected due to the 'feed' method being deprecated.
So my questions are:
A) If you have a website providing a paid service, how do you allow your users to post to their feeds, using the newer share method, with data you'd like? Eg: "I just completed the Get Moving III workout at teamexos.com!" The post would contain no pics or links. If it had to, a link to teamexos.com would be ok.
B) How do paid sites provide open graph actions and stories? Do they have public links to their products? Do those products have their own individual pages, with their own open graph tags?
First of all, the feed dialog is not deprecated, at least not anymore. You do not need to get anything approved for it, and you certainly don´t need login: https://developers.facebook.com/docs/sharing/reference/feed-dialog/
But: Your example looks like an Open Graph story, you should consider taking a look at those: https://developers.facebook.com/docs/sharing/opengraph

Facebook Development - Simple question on best approach

I am a PHP developer, but completely new to this Facebook stuff and am getting all confused. The whole Apps vs Pages vs Fan Pages terminology is driving me nuts. Please help!
My client's requirements:
1) Display Like button on a single web page
2) When Like button is clicked, content on the page is unlocked and displayed (PHP)
3) Future visits to the page detects that visitor already likes the page, and content remains unlocked (PHP)
4) All updates to web page profile on FB will show on Likers' news feed
My understanding is that the cleanest way of doing (3) above is to use the PHP SDK. But to do this, I need to create an app (to get the App ID). So I created an App. I 'liked' the App from my FB profile. Updates to my app are posted to my news feed. So far, so good.
However when I try and implement the PHP SDK, it only works if I authorize the App to my account first. Is there a way of avoiding this authorization step just for a simple "Like" (I ask because I didn't have to authorize anything when liking the app within FB)? If this authorization is unavoidable, are there any alternatives to Apps that would allow me to achieve the above requirements?
Ideally, I'd like to use just "Pages" to do this, and not Apps, but I believe I cannot achieve (2) and (3) with pages, correct (remembering everything needs to be server side, so no JavaScript showing and hiding layers etc)?
I would be grateful for any guidance.
Thanks.
So I'm assuming what we are talking about here is a Facebook tab - the 520 pixel wide applications that can go in Fan pages?
If not, you will not be able to make this happen without permissions. It sounds like that is what you're talking about, though.
Here's an example of an Facebook tab on the Coca Cola fan page:
In a tab, the PHP SDK will tell you if the user is a fan of the page (not of the app, of the page). You'll need to read the signed request - there will be a parameter there called Page, which tells you if the user is already a fan (see https://developers.facebook.com/docs/authentication/signed_request/). You get this without having to authorize.
I usually read all this and store whether the user is a fan in a boolean variable. Then later in my page I'll do something like this:
<?php if ($isFan):?>
Content for fans here
<?php else:?>
Content for non-fans here
<?php endif;?>
Keep in mind that it is only telling you if the user is a fan OF THAT PAGE - if you set up your app on a test page, for instance, it'll tell you if the user is a fan of that test page or not, NOT if the user is a fan of your app.
In order to read what a facebook user likes using the PHP SDK, you will need the user_likes permission. You may however, be able to hack something together by rendering a like button on your page somewhere and detecting the color of the button, meaning the user has liked the page. This may be problematic because of cross domain issues considering the like button is rendered as an iframe.
Best of luck!
For some things, you need an app. Like restricting access to content if the user has "Liked" something. You need custom code to do that. You don't need an app for a basic "Like" button, but you really can't get any stats on the Likes. You can link an app to a website, so that you can report on the content and referrals. If you go to http://www.facebook.com/insights/ you can link the app with a website so the insights/reporting are combined. Just click on the "Insights for your Website" button. It does require validation.
That said, your confusion is the norm. Apps, Pages and Fan Pages are almost the same thing. They are all referenced through numerical ID. There are subtle feature differences between Pages and App Pages. An app can be added to any Page if it is configured to do so. But you can't add a Page to another Page.
You can use FQL to query if a user is a fan of your app, instead of the Page you are currently on.
Facebook controls what gets shown in the news feed. Just because you post to the feed, doesn't mean it will show. However, if you are an admin of the Page and/or App, posts will always show in your feed.

Problem with like it button and public permissions

I'm a web developer and i'm having problems using the "like it" button
I put the buttom on my site as a counter of votes of a special contest. People can only click the like buttom if they are fan of my Facebook page.
The problem is that people can't vote if they haven't public permissions on his facebook, cause i can't know if they are or not fans of my page.
Is there a solution?
if you rely on information that you are not certain that you can obtain then sadly there is no solution.
Since what you are doing is beyond a simple like button What you may want to try is open a facebook application and request from your users the user_likes permission. You can read more about it here. I have photo albums on the "highest privacy setting" - only me. Yet when I request a list of my photo albums through one of my applications (with the required permissions of course) I get back ALL of my albums.. This might have been a temporary issue that was solved - but in any case - I saw this behavior and I thought it might be relevant to this post :)
Additionally you should look at the Promotions Guidelines specifically this point :
You must not use Facebook features or functionality as a promotion’s registration or entry mechanism. For example, the act of liking a Page or checking in to a Place cannot automatically register or enter a promotion participant.
I had some problems with facebook on this issue - you are not allowed to require someone to "like" a page in order to participate in an activity that is not directly connected to that page.
From what I understand you are requireing people to like your page on facebook beofore voting on your site... If this IS the case then facebook might very well start taking action and closing your page/app.

Liking a page on behalf of a user?

I'm trying to get a user to 'Like' a page via the SDK. User is signed in and I get a valid access tokken form the cookie. My APP has asked for permissions read_stream and publish_stream. I can successfully do things like post to their wall, etc. But when my APP tries to 'Like' a page, I get the error back:
OAuthException: (#3) Application does not have the capability to make this API call.
Am I missing some other permission, or is there a setting I have to turn on in my APP? I'm at a loss here.
You can't like a Page on behalf of a user (Bugzilla discussion). You can, however, like posts, comments, and photos on behalf of a user.
Edit 7/9/2012
Since bugzilla no long exists, the bug linked above is inaccessible. Google doesn't have a cached version of the page, so I ran another search. The best thing I could come up with was this Google Code Discussion regarding the ActionScript API.
Facebook makes brief mention of Publishing likes via the Graph API in the documentation, but doesn't say one way or another whether you can like a Page on behalf of a user - just "Objects" which (probably arguably) are not "objects" in Facebook-lingo.
My thought is, the API to like page is available, but is only offered to white listed applications (such as, the Facebook iOS and Android applications) written by "special" publishers. There's obvious reasons why Facebook wouldn't want/allow developers to create like connections on the graph. It would be taken advantage of by spammers and other nefarious developers and would deteriorate the meaning of what a "like" represents for a page on Facebook.
My guess is, you'd have to make a pretty strong case to Facebook about why you need/want access to the Page's Like connection (for publishing) before they'd even consider giving you access. I'd also guess that they'd want to verify that you're doing only user initiated like creations (in such a way that the iOS application would handle it) so as to protect the reptutation/meaning of a "like" action.
Actually this is NOT true, but you have to do a complicated Javascript / UIWebView process in order to display a Facebook 'page' of JUST the like button on your view, and this like button you can configure in the JavaScript / Objective-C (using string replacement) to be any Facebook page url you like.
Facebook's platform policies don't allow for a web-based like button aside from using the officially supported options
Those options doesn't require using OAuth or the Open Graph api. However, facebook just added support for mobile apps to send like actions through opengraph.
I'm not sure if they intend to allow sites to customize their like buttons or just apps...
Liking works for me with the iOS SDK using the graph api:
https://developers.facebook.com/docs/opengraph/actions/builtin/likes/

Facebook page apps - Authorizing a user

I can't seem to find exactly what I'm looking for. We're trying to build an app to run solely on a Facebook Page. We want to show a landing page if they don't Like the page, and the contest entry form if they do. This functionality works.
Before showing the contest entry form, we'd like to authenticate the user viewing the app so that they can just hit "Enter the contest!" and we can automatically pull a name/email address.
Any of the methods of authentication I've seen described, including through the Facebook Developer docs, don't work at all.
I saw something that said they need to interact with the app first, then you can get the id, but that doesn't work either. I also don't get the page id passed with the signed request.
Its also pretty unclear whether I should be using an iframe or just FBML.
Could anyone point me in the right direction, please? Thanks!
You need to create a fan page and add the FBML plugin to that page, then you will need to insert a short code that will determine if a facebook user has clicked 'Like' or not and by determining that you will decide weather to display the content of the landing page or not (using an iframe). You will probably like to also set the FBML box that you create as the default view for members who didn't press the 'Like' button yet, you can change the default view in your fan page settings.
On the iframe, you will need to use the Facebook API if you want to retrieve any user information from Facebook, for that, you will need to register a new application with Facebook. Go to developers.facebook.com for the API integration and app registration.
Also, what do you mean when you say:
Any of the methods of authentication
I've seen described, including through
the Facebook Developer docs, don't
work at all.
Well, it appears you can't do it that way. The client was very specific in wanting that functionality but we ended up convincing them to go for a redirect to the canvas page to have the app authorized and the contest entered instead.