Facebook APIs using checkins as an entry to raffle - facebook

I've been exploring ways that it might be possible to promote the business of a friend of mine. One of these ways is by encouraging users to check in to his business, the incentive for this being that they go into the draw to win some kind of prize.
I've been trying to find if the code for this already exists but I might be looking in the wrong places. If it doesn't what would be the best way to do it using the graph APIs.
Thanks.

You can use Facebook app to check-in to your page/business.
All page check-ins can be fetched using following request by your code
https://graph.facebook.com/PAGE_ID/checkins?access_token=PAGE_ACCESS_TOKEN
If you want to get only specific time period check-ins use since and until params in query.
You have to parse the json response and store in an array and randomly select the winner.
you can contact the winner using their facebook id and send them a message.

You will have to write the code yourself, but it would essentially work like this:
Get the user to allow access to the "Raffle" application and get their email address and permissions to look at their check-ins. Email is required to contact the winner.
Use a scheduled script (cronjob) to periodically check if the user has checked-in anywhere (in particular, the business you want to promote).
Award a raffle ticket for each unique check-in within a 24 hour period.
Hold a draw between all the users who checked in on that day or week and award the prize to someone randomly.
Pretty simple flow, but complex code.

Related

How to send message to specific facebook user from website?

My goal is to make a website, in which user could customize a photo and then provide his friends indicators like name or id. My next task is to fetch that info from database and send messages on specific date to provided users. Ex birthday wishes, greetings, and so on.
I studied facebook send api for a few days now and couldn't find solution for myself. If I want to send message, I need to have Page-scoped id of user, which is acquired when the person text you first, which is not desired, because person wouldn't know what it is.
Also I was looking into Customer matching API, also seems to require the same PSID. The next thing I checked was Send Dialog API, which seems to send messages instantly, but not on the specific date. Also I checked unofficial facebook-chat-api, which asks for user ID, whereas I can find my id, I couldn't find ids of my friends.
So I just want to know is it even possible, if yes, I'd really appreciate your help.
User to User communication is not possible (and not allowed) in an automatic way, there is no API for it except for the Send Dialog. The Messenger platform is for page to user communication only.
Do not use inofficial tools, they are not allowed and might get you banned.

Retrieving friend count delta

I've been looking through the Facebook-graph API for a way to get a kind of 'delta' of friend changes since a given date. it looks like the /<id>/friends end point will give me a total count at the current time. What I'd like is that same value but for a historic date (i.e. where the date is this time last year, so that I can see how many friends someone has made/lost since then).
(I was originally hoping Facebook would just let me see when people became friends, but it looks like a user's friends list, and all the related details, are off limits).
Unfortunately I can't just rely on the use of future dates, though that may be the solution I end up with (as in, I request the count at the current date, and then at some point in the future request it again and compare the difference).
I can see from my own Facebook account that they do track when a friend/connection was made, and I'm not looking to dig up details on the friend/connection. Ideally I'm looking for something like /<id>/friends?asat=<date>
As a follow up question assuming this feature isn't available through the facebook-graph API, how would I go about requesting this feature for a future version?
There is no way to get the history, you can only call the API endpoint on a regular basis and store the difference with date on your own.
Feature requests can be sent here: https://www.facebook.com/help/contact/268228883256323
...although, i doubt that they will implement this, to be honest. Those kind of "insights" are usually only available for Pages, but not for User Profiles.

rails beta request signup with social media sharing reward

I would like to build a simple beta request signup page where the user is rewarded with an earlier reward when he is sharing the link to the application as much as possible.
A solution like this is seeable on
trenvy.com
User enters email
User gets unique link with his unique code
User shares this link on every signup its a +1 count on him
An admin method throws out the users emails which have shared the link and brought the most people in. I want to use this email list to use in CampaignMonitor.
Anyone knows what could be a good way to achieve this? Or someone wrote such a thing or knows a git repo that has this feature implemented as is to take a look at and learn?
I have already coded a unique code generator for the app that makes unique codes of 10 chars.
Now only this social media sharing is a bit unclear to me on how to approach this in rails, any ideas on that? thx!
Something like this can be achieved pretty easily in any framework, so I think I'll provide a general answer first, and if any specific gems occur to me, I'll mention them:
1) The unique code part is easy, it's just a parameter in a controller that checks the validity of the code — this would be a unique code that's added to the user model for ease of verification and created when the user first enters his email address.
2) Every time the link is visited, it's parsed by the controller and saves an event (don't just increment a field if you want maximum data out of the interaction, you could save IP for country of origin, time of the page hit, etc), just count the click events for that user for his +1s
3) Just write a quick admin site (i used twitter bootstrap for this recently) that lets you see the user's who've interacted with the system and sort by shares, and you can use the createsend gem to add them to whatever list you like.
There are no specific gems I can think of that'll speed this process up, Devise is overkill, you don't really need an activity monitor gem since you're not storing much info, definitely twitter_bootstrap for speeding up building the admin interface. Heroku lets you add an Sendgrid as a plugin, so you're covered there for mail sending.
Am i missing anything in your requirements? Seriously though this should be a 2-4 day dev effort, nothing fancy here.

Adwords Impressions, Clicks and Cost, how to get these?

I'm developer for marketing company and I need some help with facebook ads. I've been trying to find method for getting data AUTOMATICALLY from facebook campaign that's created by the user.
I'm trying to create script that would get data for server.
So basically I need to get Impressions, Clicks and "Cost of clicks" from each day from facebook-ad-campaigns just by having user login data (username,password) and maybe the id-number of campaign being targeted.
Also if possible I'd like to know how you can shut down campaign(when cost of clicks is greater than budged used).
Are these operations possible? Can I use PHP/FQL for it? Can I get these via Url? If I need to use FQL, what tables I need to fetch data? Anything that can be performed without manually logging to facebook? If so, could I get some example code to do it for me? If it has something to do with Access Tokens, what kind of access rights do I need to grant for it?
Can it be possible to ask more questions in one question than you just did? Wow.
Answers are in order of them asked above. But I will not be answering any followup questions in this thread.
For most of your information can be found at: http://developers.facebook.com/docs/reference/ads-api/
In your code, set a trigger when it has reached that value in the adstatistics, then use the Ads API to shut it down using the pause feature
Yes, use the Ads API. http://developers.facebook.com/docs/reference/ads-api/
For some parts of it you can, for other parts you'll use Graph API object.
Yes, that's how the graph works.
Tables are listed in the documentation at http://developers.facebook.com/docs/reference/ads-api/
Nope.
Yep, example codes are there.
Yes, it sure does.
see https://developers.facebook.com/docs/reference/api/permissions

Using GA Data Export API to Get All UA's

I am using the GA Data Export API to interact with Google Analytics and I'm making a lot of progress, I am using this URL Endpoint initially to pull all the profiles under an account:
https://www.google.com/analytics/feeds/accounts/default
This URL retrieves each GA ID (profile) and each UA. One thing I've realized is one account can contain multiple UAs and when this happens, this request pulls all profiles. We have a client who has about 115 profiles under like 10 different UAs, and the request takes about 30 seconds for the initial request (and then I believe it must be cached, because it speeds up considerably after this, but then the next day the same thing occurs).
Is there a way to get a list of UA's without pulling the profiles? This way I can query the UA specifically for the profiles instead of pulling each one.
Any advice on this would be really helpful!
Thanks
UPDATE: Here's some documentation on the specific call I am using right now:
http://code.google.com/apis/analytics/docs/gdata/gdataReferenceAccountFeed.html
UPDATE 1: I have found some interesting information in the docs
Once your application has verified
that the user has Analytics access,
its next step is to find out which
Analytics accounts the user has access
to. Remember, users can have access to
many different accounts, and within
them, many different profiles. For
this reason, your application cannot
access any report information without
first requesting the list of accounts
available to the user. The resulting
accounts feed returns that list, but
most importantly, the list also
contains the account profiles that the
user can view.
So this means that you have to use the default accounts call to get these back? Surely, somebody has had this issue before?
So apparently, you can query the account if you know the UA-ID, however there is no way to get back a list of only UA IDs.
One way you can do it is have the user enter their own UA ID instead of having them choose one; not as user-friendly as it could be but better than making the user wait 30 seconds!