Created
February 19, 2010 21:09
-
-
Save facebook/309215 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="fb-root"></div> | |
<script src="http://static.ak.fbcdn.net/connect/en_US/core.js"></script> | |
<div id="content"> | |
<div align="right"><fb:login-button autologoutlink="true" v="2"></fb:login-button> | |
</div> | |
<h1>Recipes For You on Facebook</h1> | |
<h3>Peanut Butter and Jelly Sandwich <button onClick="triedIt();">I Tried This!</button></h3> | |
2 slices bread<br> | |
1 T peanut butter<br> | |
1 T jelly<br> | |
<br> | |
Using knife, spread peanut butter on one slice of bread. Using a clean knife, | |
spread jelly on the other slice. Put slices together so that the peanut butter | |
and jelly meet. If desired, cut into squares or triangles. | |
<center> | |
<fb:share-button href="http://apps.facebook.com/example" type="button_count"> | |
</fb:share-button> | |
</center> | |
</div> | |
<div id="data"></div> | |
<script> | |
function triedIt(){ | |
var post = { | |
message: 'I tried the Peanut Butter Sandwich recipe.', | |
attachment: { | |
name: 'Recipes', | |
description: ( | |
'This is the site to go to for great recipes!' | |
), | |
href: 'http://www.yoursite.com' | |
}, | |
action_links: [ | |
{ | |
text: 'Check Out the Recipes', | |
href: 'http://www.yoursite.com' | |
}, | |
], | |
user_prompt_message: 'Share your thoughts about the Peanut Butter Sandwich recipe!' | |
}; | |
FB.publish( | |
post, | |
function(published_post) { | |
if (published_post) { | |
alert( | |
'The post was successfully published. ' + | |
'Post ID: ' + published_post.post_id + | |
'. Message: ' + published_post.message | |
); | |
} else { | |
alert('The post was not published.'); | |
} | |
} | |
); | |
} | |
</script> | |
<script> | |
FB.init({ | |
apiKey: 'd384fe048a4a1c3894fbc17f2118ad94', | |
status: 'true' // Mention why some people might want to use getLoginStatus() instead | |
}); | |
FB.XFBML.parse(); | |
</script> | |
<script> | |
FB.getLoginStatus(function(response) { | |
alert("Hello!"); | |
if (response.session) { | |
alert ("Got a session"); | |
FB.api( | |
{ | |
method: 'fql.query', | |
// query: 'SELECT name FROM profile WHERE id=' + FB.getSession().uid | |
// query: 'SELECT page_id FROM page_fan WHERE uid = ' + FB.getSession().uid | |
query: 'SELECT name, pic FROM user WHERE is_app_user = 1 AND uid in ' + | |
'(SELECT uid2 FROM friend WHERE uid1 = ' + FB.getSession().uid + ')' | |
}, | |
function(response) { | |
if(response.error_code){ | |
alert("Error " + response.error_code + " in FQL query: " + response.error_msg); | |
} else { | |
for (i=0; i < (response.length > 5 ? 5 : response.length); i++){ | |
document.getElementById('data').innerHTML += "<img src=\"" + response[i].pic + "\">"; | |
} | |
} | |
} | |
); | |
} else { | |
// no user session available | |
alert("No session!") | |
} | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment