how to integrate with facebook timeline to share activities? - php

I want to integrate with facebook timeline so that each activity on my website gets shared on user's facebook timeline.
i earlier used to use the publish stream permission to publish the activities on user's wall, and a second dialog comes for the publish stream permission while getting signed up on my website.
however i have recently observed that some sites are doing something different, while getting signed up on these sites, you will never get second dialog for publish stream permission and each activity will be shared n fb wall.
will be great if someone could explain me in detail, also i am doing all this in php.

What you're describing is Open Graph actions (OG). Instead of 'publish_stream', OG-enabled sites are using 'publish_action' which doesn't require confirmation. All OG actions are published against OG objects, which are usually webpages. Have a look at the introduction to Open Graph at https://developers.facebook.com/docs/opengraph/, then follow the tutorial at https://developers.facebook.com/docs/opengraph/tutorial/ to see how to implement it for your site.

Related

What is Facebook app canvas and page tab?

I have spent a lot of time reading FB dev docs and tutorials but I am still very confused with what canvas app and page tab are and how to use them.
What I am expecting from using FB SDK in my site is to have "continue with facebook" button on login screen , have a couple of share and like buttons and send notifications to facebook if user have allowed that. My site has internal messaging system and I want to notify users that new message or activity has happened in my site. In this way users would not have to check my site every day for activity which is important user experience as I expect rare activity(approx. few activities per week).
I have everything running but after user clicks on notification he is taken to canvas app. FB docs and tutorials focuses on code examples but I have not found anywhere description on what canvas app really is. Without this fundamental understanding I can not complete my notification logic, can not understand the terms involved like "secure canvas url" and basically does not feel confident about user experience(which I would want to make as great as possible).
If I google "what is facebook canvas app" I get "Canvas is an immersive and expressive experience on Facebook for businesses to tell their stories and showcase their products.". Apparently from comment below thats something else...
I would appreacite If someone could explain in plain word and maybe example what is canvas app and how should I use if taking into account that my main goal is to notify users about acitivity in my site to their fb account.
I am using CI framework PHP SDK v5.
Background
In Facebook, you create "apps" that run on "platforms". As a quick, very simplified summary, the three primary types of "platforms" that apps can run are:
A website that you host and control, but integrated with the Facebook Graph API (has Facebook Login, posting etc), but otherwise looks like a normal website. You host these on your own servers.
A website designed to sit inside an iFrame on the Facebook Platform. These apps will also generally interact with Facebook Graph. You still host them on your own servers but you have the added advantage that but can get limited information about the user when the page loads.
Stand alone programs (including mobile applications) that also interact with the Facebook Graph.
What you are talking about is the second of these - the iFrame on Facebook.
Facebook provide two ways to embed the application iFrame:
one is a canvas app. This has minimal surrounds for Facebook Header, Footer and a few ads on the right. It maximises your space. (e.g. https://apps.facebook.com/candycrush/?fbs=-1&fb_appcenter=1)
the other is a "page tab" (https://developers.facebook.com/docs/pages/tabs). This is smaller and designed to sit in a company's "Facebook Page" so has less space. As a marketer, however, it keeps everything more branded to your company. (Example: https://www.facebook.com/NutellaANZ/app/595447743881506/)
Note that a single app can run across all the above - canvas, a page tab and a stand-alone HTML page. With some shifting of the API, you can also wrap the same code for mobile and put on the app stores. A user can log in on your mobile app and you can have them logged in on websites and vice-versa (within some limits, but you'll need to explore those).
Games Only?
You are right in that most of the Facebook docs relating to apps refer to games.
Indeed a good place to start is https://developers.facebook.com/docs/games/gamesonfacebook which is where help leads you for Canvas Apps now.
But it doesn't have to be a game - so long as you're using the APIs anything will work. As you mention PHP, have a look at https://developers.facebook.com/docs/php/howto/example_access_token_from_canvas - no mention of a game, but is how you get information from the iFrame in PHP. (There's a lot more reading to do!).
Reading notifications
When clicking on the notification, Facebook will add parameters to the URL. Some of these are determined by the notification (see https://developers.facebook.com/docs/games/services/appnotifications) and others will help you get information about the user (https://developers.facebook.com/docs/reference/login/signed-request, https://developers.facebook.com/docs/php/SignedRequest/5.0.0).
So use this information server-side to work out who the user is and how you want to handle the user. But what experience you want to give the user once you're in the Facebook eco-system is up to you.

PHP Facebook SDK publish posts in Fan Page

I have created an account in Facebook Developers, and I've generated the token with long live (never expire). I've correctly published the post with my script PHP. The problem is that the only person who can read it is me. It isn't published in my Fan Page. It is neider published in my personal profile. It is in an intermediate point between my personal profile and my Fan Page.
The app created in Facebook Developers is active and published. I just want to publish my blog posts in my Fan Page.
The permissions configured in my Access Token are: manage_pages and publish_actions. I have in another platform and it works perfectly. Can you give me any suggestions? Thank you in advance.
Your app is not made public yet (check app dashboard, Status and Review tab, “Do you want to make this app and all its live features available to the general public?”) – as long as it is not set live, all content created through it will only be visible to you.
You always need to do this for each api key.

Use facebook sharer.php to share on a page wall

I want to link a user to make a share post on my fb company page without having to authenticate. Currently I can get them to share on their own wall with:
But I'm not sure how I can get this to share to a page's wall rather than their timeline.
I got somewhat close by using the dialog feature:
https://www.facebook.com/dialog/feed?app_id=xxx&link=xxx&picture=xxx&name=xxx&caption=xxx&description=xxx&redirect_uri=xxx
But that just showed it as a normal share but done "via appName", unless there is a step I'm missing to link my app to my facebook page?
Thank you!
Unfortunately, the sharer.php method is used only to share only on the user's timeline.
If you want to ask the user to post on a page's timeline, you have to create an app, ask the user to authenticate it and then use the Facebook APIs to post on their behalf. I guess that will be cumbersome in your case, so I would just suggest you redirect to the particular Facebook page.
You can't !
To publish on YOUR page timeline, users need to have the rights to do it (be admin, writer, ...) : it's a manual requirement on the Facebook interface.

Show website activities on Facebook timeline?

How can I show website activity on the Facebook timeline?
I integrated Facebook API and Facebook Connect. Now, if any new user uploads a video on the website then I want to display this activity on the Facebook log. What function of Facebook API can I use for this?
You should use Open Graph Actions and Objects. I recommend you create:
A video object
An "uploaded" action as well as utilising the built-in "watch" action
There is a full and more than helpful tutorial right here. Things to consider:
You need to request publish_actions permission from users of your website, if you are already using Facebook Login, then this is a simple matter of adding it to the list of Permissions that you are requesting
Publish an uploaded action for every new video uploaded, make sure you get explicit consent from the user to do so, so that you can use the fb:explicitly_shared parameter.
Use the watch action for any videos that people watch on your website.

Publishing user's activities from Facebook App

I am developing a Facebook application, and I am trying to publish the users' activites in my application in the user's wall, like when the user comments on post, the story feedback appears in his wall and is available to his friends to see
I have read these tutorials:
https://developers.facebook.com/docs/opengraph/tutorial/
As well as the following threads:
How to publish Actions to Facebook Graph API with parameters in call URL
Facebook- Publishing a story to user's wall
I am confused about which one I should follow because openGraph seems a bit complicated to implement....so what is the best practice to achieve my requirement?
If you want to post activities on users wall, open graph is preferred way and you will get large distribution(marketing) also.
You can use the PHP Official sdk from facebook, which makes you job easier.
To post open graph actions, you should take publish_actions extended permission from user.
or
You can post on user's wall using /me/feed method requires [publish_stream][3] extended permission.
SDK tutorial
https://developers.facebook.com/docs/reference/php/
Open graph sample application
Download Social Cafe app and see their code
https://developers.facebook.com/docs/opengraph/samples/
You can use Javascript SDK as well, and sometimes that is actually getting better. For example, recently Facebook enforces that users have to read for at least 10 seconds before the app publishes news:Read. These are the usecases that can be handled very efficiently with javascript sdk and jquery (or similar client-side technology).
As for April 2018,
The publish_actions permission is no longer available.

Categories