facebook canvas app - reveal page issue - php

Its a reveal page app and
The app check if the user likes the fanpage through signed_request, if not it shows an image that says like us, else it shows the content to the fan.
This works fine when someone comes to the fanpage i.e. app is running within the fanpage as a tab. e.g. http://www.facebook.com/myfanpage?sk=app_xxxxxxxxxxxxxx
If someone comes to the app directly e.g. http://apps.facebook.com/myappname it always shows the image that says like us whether user already likes or not.
Is there a way to check how the app is being accessed? directly or as a tab in the fan page? I can not use 'top.location.href' in javascript, it returns null I guess because of obvious reasons of cross domains, i.e. app is running from some other domain and not on facebook.
Regards

You can use the Facebook JavaScript SDK to call the Graph API URL in the form https://graph.facebook.com/PROFILE_ID/likes/PAGE_ID and see if the user likes your page.
See this link for documentation: http://developers.facebook.com/docs/reference/api/user/#likes

Related

Facebook click-id missing (fbclid)

I am currently running several ads on facebook and I have just started using the facebook-click-id to replace facebook-pixels for the tracking. For some reason I have found that there are a lot of clicks coming in through the ads without the fbclid-parameter attached to the url as a get-parameter.
Through a google search I have found out that the only reasons the fbclid-parameter would not be attached to the url would be that the user clicking on the ad is not logged in to facebook or that the user is using his/her browser with the incognito-mode activated.
It seems odd to me that so many clicks could happen under those circumstances. Which is why I am wondering if there are other reasons why the facebook-click-id (fbclid-parameter) would not be attached to the url.
Are there any other reasons why the fbclid-parameter would not be attached to the outgoing url of a facebook ad? Thanks!
after doing some tests trying to solve the same problem, what I noticed is that fbclid parameter did not appear in outbound links when using the browser built into the mobile Facebook app.
So, I think that this is a Facebook limitation.
Hope it helps,

$_SERVER['HTTP_REFERER'] won't get HTTP_REFERER from facebook messenger app

I have a script that get the $_SERVER['HTTP_REFERER'] when a user visits my page. This works great if it is used on facebook for desktop. But if a user click the link in the mobile app facebook messenger it can't get any HTTP_REFERER.
Anyone have a solution for getting info about if the user clicked a link in the facebook messenger app?
The problem is that when a user clicks on a link the the facebook app, it isn't being redirected, but opened. Since the app isn't a web browser.
If you wanna track where people open your site from, you could parse in a UTM code (just a _GET parameter, but globally used to track origin, many sites like google also uses these, and some even auto append them.).
For more info, see the following article: http://www.launchdigitalmarketing.com/seo-definitions/what-are-utm-codes/

Is it possible to display Facebook users timeline on website?

OBJECTIVE: I need to display latest 5 entries from users timeline on website, using PHP.
Please not that i speak about timeline of user profile - not fan page, not group.
SO FAR I DID THIS:
Registered as Facebook developer
Registered app
Obtained token
Opened url: https://graph.facebook.com/USER_ID/feed?access_token=MY_TOKEN
Voila. Feed of that user is displayed now, but..
PROBLEM: So now i have users feed, but it looks like its partially working.
It happens often that it don't displays some updates, sometimes it displays just date of the post and not the content.
However when i try to grab feed from some facebook fan page, then everything work normal.
MY QUESTION: Are we allowed to grab user timeline? If yes, what im doing wrong?
You won't ever see all the information that is visible inside the Facebook app via the api. This comes from how Facebook filters out the data. See this Facebook Developers blog post for more information: https://developers.facebook.com/blog/post/478/
Yes you are allowed to to grab user timeline posts, even with a limit, if your app asks for read_stream permission. Issue an HTTP GET request to the below URL:
https://graph.facebook.com/user_id/posts?access_token=token&limit=5

Can a page tab post to a user's wall?

I have a Facebook application used as a tab in a fan page, that displays different information depending on whether tha user is a fan of that page or not.
Now I've been asked to have it post a message to a user's wall if they perform certain action (follow a link or whatever), and so far I haven't found a way to do that. All the documentation I have found refers to stand alone apps, and I've even seen it suggested (in the FB forums) that you can't get the auth token from an app.
So, i still think it can be done, but how?
If a user has authorized your app, you can post to her wall using the PHP SDK. See the PHP SDK api documentation for examples.
All apps have to be iframe apps now, so loading the JS sdk should be fine.
You have to get permissions first ->
http://developers.facebook.com/docs/authentication/#applogin
Then you can post using php with what Dhiren said, or, post with the fb.api function with JS ->
http://developers.facebook.com/docs/reference/javascript/FB.api/
Let me know if you need an example script.
Cheers

problem with description tag for FB sharer

I wanted to know how does FB sharer work. I wanted to share different things with FB when the user is logged into my website and not into my website. So i had 2 description tags i.e different for logged and not logged in users. But FB sharer is not recognizing it. It just displays only 1 description tag while sharing. I have used the FB lint also. Same problem i have there.
Does the user criteria does not work while sharing to FB?
The content that is displayed when a user shares / likes from your site is based on a scrape that is pulled every ~24hrs. If you're displaying a different page for logged in / logged out, then the Facebook servers can only see the logged out content and hence that's what's getting displayed from a share / in the linter.
If you check your server logs, you'll see a user-agent of facebookexternalhit/1.1. That's the Facebook Spider. Off the top of my head and without knowing your site's architecture, I can't really offer a good solution of how you'd provide FB with both versions, but at least you know what's causing the issue.
Well i think you should try facebook fb.ui method:
Example: http://fbrell.com/fb.ui/feed
Docs: https://developers.facebook.com/docs/reference/javascript/FB.ui/
With this method, you can easily customize your messages and also you can set different for logged in users and for guest visitors.
BTW to get that working, you should first add facebook js sdk

Categories