Skip to content

Instantly share code, notes, and snippets.

@nbhartiya
Created May 24, 2014 03:19
Show Gist options
  • Select an option

  • Save nbhartiya/13d911878aaa55184134 to your computer and use it in GitHub Desktop.

Select an option

Save nbhartiya/13d911878aaa55184134 to your computer and use it in GitHub Desktop.
function postStory() {
var desc = 'Click to play games and learn '+ capitalizeFirstLetter(toLanguagePreference)+' with your fun and studious friend, '+ $('.userName').text() + ', now! '+$('.userName').text() +
' just learnt how to say ' +
((toLanguagePreference.toLowerCase() == 'mandarin') ?
lastLearntWords[0].word + ', ' + lastLearntWords[1].word + ', ' + lastLearntWords[2].word + ', and more in ':
lastLearntWords[0].meaning + ', ' + lastLearntWords[1].meaning + ', ' + lastLearntWords[2].meaning + ', and more in ') +
capitalizeFirstLetter(toLanguagePreference) +
'. Give this a "like" to encourage your friend!';
FB.api('app/objects/' + APP_NAMESPACE + ':word', 'POST', {
'access_token': APP_ID + '|' + APP_SECRET,
object: {
title: $('.userName').text() + '\'s new ' + capitalizeFirstLetter(toLanguagePreference) + ' words',
description: desc,
image: 'http://new.culturealley.com/img/nerdy-monster.png',
url: 'http://new.culturealley.com/?utm_source=facebook&utm_medium=LearntWordStory&utm_campaign=FBLearntWordStory',
ref: 'learntwords',
data: {
language: capitalizeFirstLetter(toLanguagePreference),
count: '5'
}
}
}, function(r1) {
console.log('r1:', r1);
if(r1.id != undefined) {
FB.api('me/' + APP_NAMESPACE + ':learn', 'POST', {
word: r1.id,
privacy: {'value': 'EVERYONE'}
}, function(r) {
console.log('r:', r);
});
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment