Contenu connexe Similaire à Facebook Apps: Ein Entwicklungsleitfaden - WMMRN (20) Plus de Stephan Hochdörfer (20) Facebook Apps: Ein Entwicklungsleitfaden - WMMRN2. Facebook Apps: Entwicklungsleitfaden
Über mich
Stephan Hochdörfer, bitExpert AG
Department Manager Research Labs
S.Hochdoerfer@bitExpert.de
@shochdoerfer
http://www.facebook.com/shochdoerfer
6. Facebook Apps: Entwicklungsleitfaden
Die Graph API: REST + JSON
{
"id": "1047746467",
"name": "Stephan Hochdoerfer",
"first_name": "Stephan",
"last_name": "Hochdoerfer",
"link": "https://www.facebook.com/shochdoerfer",
"username": "shochdoerfer",
"gender": "male",
"locale": "de_DE"
}
9. Facebook Apps: Entwicklungsleitfaden
Die erste Facebook App
<!DOCTYPE html>
<html xmlns:fb="https://www.facebook.com/2008/fbml">
<body>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId: 'your app id',
status: true,
cookie: true,
xfbml: true
});
};
(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>
12. Facebook Apps: Entwicklungsleitfaden
Fan oder Nicht Fan?
<?php
$request = $facebook->getSignedRequest();
$isFan = isset($request['page']) &&
isset($request['page']['liked']);
?>
13. Facebook Apps: Entwicklungsleitfaden
Login / Authentifzierung
FB.getLoginStatus(function(response) {
if (response.session) {
// User eingeloggt
} else {
// Versuchen den User einzuloggen
FB.login(function(response) {
if(response.session) {
if(response.perms) {
// ist eingeloggt....
}
}
}, {
perms: 'publish_stream, offline_access'
});
}
});
14. Facebook Apps: Entwicklungsleitfaden
Wallpost (JS Style)
var pageId = 12345678;
var post = {
message: '',
name: 'Der Name des Links',
caption: 'Die Beschreibung',
link: 'http://www.facebook.com/'+pageId,
attribution: 'Meine App'
};
FB.api('/'+pageId+'/feed', 'post', post);
15. Facebook Apps: Entwicklungsleitfaden
Wallpost (PHP Style)
<?php
$pageId = 12345678;
$post = array(
'message' => '',
'name' => 'Der Name des Links',
'caption' => 'Die Beschreibung',
'link' => 'http://www.facebook.com/'.$pageId,
'attribution' => 'Meine App'
);
$facebook->api('/'.$pageId.'/feed', 'post', $post);
17. Facebook Apps: Entwicklungsleitfaden
FQL (JS Style)
FB.api({
method: 'fql.query',
query: 'select first_name,last_name,email from user
where uid = me()'
},
function(response) {
console.log(response);
});
18. Facebook Apps: Entwicklungsleitfaden
FQL (JS Style) - Subselect
FB.api({
method: 'fql.query',
query: 'select first_name,last_name,email from user
where uid IN (SELECT uid2 FROM friend WHERE uid1 =
me())'
},
function(response) {
console.log(response);
});