Skip to content

Instantly share code, notes, and snippets.

@peteroome
Last active December 16, 2015 01:19
Show Gist options
  • Save peteroome/5353843 to your computer and use it in GitHub Desktop.
Save peteroome/5353843 to your computer and use it in GitHub Desktop.
Twitter Web Intents
class window.FSocial
constructor:->
@links = $ '.share-links'
@fbLink = $ '.facebook', @links
@channelUrl = @links.data('channel-url') + "/channel.html"
@bindTwitter()
@bindFacebook()
bindTwitter: () ->
reward = @rewardCredits
twttr.ready (twttr) ->
twttr.events.bind 'tweet', (event) ->
reward()
bindFacebook: () ->
window.fbAsyncInit = () ->
# init the FB JS SDK
FB.init
appId : '151462501671714', # App ID from the app dashboard
channelUrl : @channelUrl, # Channel file for x-domain comms
status : true, # Check Facebook Login status
xfbml : true # Look for social plugins on the page
@fbLink.click @facebookShare
facebookShare: (event) =>
event.preventDefault()
target = $ event.currentTarget
FB.ui
method: 'feed',
name : target.data('facebook-name'),
link : target.data('facebook-link'),
picture : target.data('facebook-picture'),
caption : target.data('facebook-caption'),
description : target.data('facebook-description')
, @facebookResponse(response)
facebookResponse: (response) =>
if response and response.post_id
@rewardCredits()
rewardCredits: () =>
url = @links.data('reward-url')
console.log url
$.post url
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment