Created
January 31, 2011 19:52
-
-
Save greut/804679 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
<!doctype html> | |
<html lang=en> | |
<head> | |
<meta charset=utf-8> | |
<title>my app!</title> | |
</head> | |
<body> | |
<div id="fb-root"> | |
<button id=auth>Authorize</button> | |
<p id=status></p> | |
<pre id=token></pre> | |
</div> | |
<script> | |
var appId = '…'; | |
window.fbAsyncInit = function() { | |
FB.init({appId: appId, status: true, cookie: true, | |
xfbml: false}); | |
var logged = function() { | |
document.getElementById('auth').style.display = 'none'; | |
document.getElementById('status').innerHTML = 'Logged in.'; | |
accounts(); | |
}; | |
var accounts = function() { | |
FB.api('/me/accounts', 'get', {}, function(response) { | |
if(response.data) { | |
var html = ''; | |
for(var i=0,page; page=response.data[i]; i++) { | |
if(page.name) { | |
html += page.name + " (" + page.id + "): \r\n" + page.access_token + "\r\n\r\n\r\n"; | |
} | |
} | |
document.getElementById('token').innerHTML = html; | |
} | |
}); | |
}; | |
FB.getLoginStatus(function(response) { | |
if(response.session) { | |
logged(); | |
} | |
}); | |
document.getElementById('auth').onclick = function() { | |
FB.login(function(response) { | |
document.getElementById('status').innerHTML = response.perms ? | |
'Thanks!' : | |
'Fail'; | |
if (response.session && response.perms) { | |
logged(); | |
accounts(); | |
} else { | |
document.getElementById('status').innerHTML = 'fail'; | |
} | |
}, {perms:'publish_stream,offline_access,manage_pages'}); | |
}; | |
}; | |
(function() { | |
var e = document.createElement('script'); e.async = true; | |
e.src = document.location.protocol + | |
'//connect.facebook.net/en_US/all.js'; | |
document.getElementById('fb-root').appendChild(e); | |
}()); | |
</script> | |
</body> | |
</html> |
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
<?php | |
require 'php-sdk/src/facebook.php'; | |
// Get those from and for your facebook application | |
$pageId = '…'; | |
$accessToken = '…'; | |
// those two aren't needed | |
$fb = new Facebook(array( | |
'appId' => null, | |
'secret' => null | |
)); | |
$fb->api( | |
'/'.$pageID.'/feed/', | |
'POST', | |
array( | |
'message' => 'Hello!', | |
'access_token' => $accessToken | |
) | |
); |
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
import facebook | |
# get those from and for your facebook application | |
page_id = '…' | |
access_token = '…' | |
obj = {'message': 'Hello!'} | |
fb = facebook.GraphAPI(access_token) | |
fb.put_object(page_id, 'feed', **obj) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment