Showing posts with label Facebook. Show all posts
Showing posts with label Facebook. Show all posts

Tuesday, April 17, 2012

Knowing when someone shared your page

Three major players


I usually focus on the three major players in the social media arena. Facebook, Twitter, and Google+. Sorry to all of the other players like LinkedIn, etc.

How to track who shared your page(s)


On each page where you have the Facebook like, Twitter tweetbox, and Google Plus's +1 button, simply subscribe to the callbacks specific to each environment.




Then in your callback functions, just AJAX whatever you want back to your server for it to store. :)



Happy Coding!

Facebook Access Tokens in a nutshell

Three different types of access tokens


APP access tokens

are used to get information that your app is privileged to access from the Facebook Graph API. And in some cases where publish_stream is granted from an app user, you can use it to post to that user's wall, without needing a USER access token.

USER access tokens

are given to your app and they relate to the permissions a specific app user has granted to your application so you app can act on their behalf when interacting with the Facebook Graph API.

PAGE access tokens

are given to page admins so they can act on behalf of the page. To go from a user access token to a page access token, call /me/accounts using the user access token to get a list of pages they admin along with each pages access tokens.

Useful tips


If you have an access token and you want to know more information about it, lint it at Facebook's URL and access token debugger.

For more information on access tokens see: Facebook's authentication documentation.

Tuesday, March 27, 2012

Facebook access tokens and offline access deprecation

Uh oh, Facebook's changing things again...

Recently Facebook announced deprecation of offline_access permissions. So the question that is most frequently asked is "How do I get a token I can use when the user is not logged in?"

So, please add this to your FAQ.

How do I get a token for offline access?

Fairly simple. When the user is logged into your app, take their current access token (usually this one expires in an hour or so) and pass it as a query string parameter to a specific URL.

That url is:

https://graph.facebook.com/oauth/access_token?             
    client_id=[APP_ID]&
    client_secret=[APP_SECRET]&
    grant_type=fb_exchange_token&
    fb_exchange_token=[EXISTING_ACCESS_TOKEN]


Replace [APP_ID], [APP_SECRET] and [EXISTING_ACCESS_TOKEN] with your application values and the current access token, and in the response from Facebook, you will get a 60 day access token.

Why is Facebook making it hard?

In my opinion, I believe it is to reduce the number of spammy apps. Facebook says it's to drive more traffic to your app and also to ensure that your app is relevant and important to the user. I've heard of Facebook also wanting to ensure that the apps become less independent and more dependent on user interaction. Most developers do hope that their app is relevant and useful to the user. And most developers are not trying to spam. However, because of the naughty ones, the rest of us have to suffer who want to do something like making it easier for marketers to schedule posts in advance.

Can I exchange my 60 day access token for a new 60 day access token?

No, sorry you cannot. You can only exchange a valid (meaning current) user access token for an extended one. You cannot extend an already extended access token.

Final thoughts

So with this knowledge, we need to make our apps more engaging and let the user know they will need to visit fairly often. For those apps that do automated work with no user interaction, this means someone will have to manually get a 60 day token (I prefer to use the Facebook Graph API Explorer Tool) and plug it into their application via refreshable settings, as opposed to hard-coded in compiled apps.

Tuesday, March 20, 2012

How to use the Graph API to search for places

Facebook has recently updated their documentation on their search* feature. This is exciting news! In this blog I want to show you how simple it is to search for places or locations in a geographical area. All you need to know is the center coordinates of the location to be searched.

* note: Facebook's made it hard to directly link to the information as they have no anchor tag in the long page. Scroll down to the "Search" heading.

To search for places near a geographical location


https://graph.facebook.com/search?q=coffee&type=place&center=37.76,-122.427&distance=1000&access_token=VALID_ACCESS_TOKEN

I believe the distance parameter is in meters, but it is hard to tell because they've left that part undocumented.

To search for objects near a geographical location


https://graph.facebook.com/search?type=location&center=37.76,-122.427&distance=1000&access_token=VALID_ACCESS_TOKEN

What's interesting is you will get check-ins from friends if you're using a user access token for this query. Here's what Facebook says:

In addition, the returned objects will be those in which you or your friend have been tagged, or those objects that were created by you or your friends. There are important behavioral differences in the results depending on the permissions your app has acquired. Please see the documentation for the location_post FQL table for more information.

Happy coding! And as always be nice to your API.


Facebook Graph API undocumented (or poorly documented) properties and connections.

I'm writing this post to shed some light on poorly documented Graph API properties and connections. All comments are welcome and I'll try to update this blog entry with the latest and greatest.


photo.backdated_time

Some information about backdated_time can be found in this stackoverflow question.


user.installed

Appears to be letting us know if the user has installed the current application. You can see this field added by specifically declaring on the Graph API call of `me/friends?fields=installed`. Yet another stackoverflow question led me to this information.


user.email

Can't seem to get the email on the user object? Well, just add `?fields=email` to your Graph API query and you now will get that information.