Contenu connexe
Similaire à Api vortrag (20)
Api vortrag
- 2. Übersicht
• Facebook – Graph API
• Twitter – REST API
• YouTube – Data API
- 3. JSON
{ <object>
"key": "vaule", ! <key>vaule</key>
"string": "Lorem ipsum dolor sit", ! <string>Lorem ipsum dolor sit</string>
"number": -123.456, ! <number>-123.456</number>
"object":{ ! <object>
! "key": "value" ! ! <key>value</key>
}, ! </object>
"array": ["foo","bar"], ! <array>foo</array><array>bar</array>
"boolean": true, ! <bolean>true</bolean>
"empty": null ! <empty>null</empty>
} </object>
169 Bytes 226 Bytes
Eine mögliche XML-Schreibweise, andere Schreibweisen sind möglich.
- 4. Parsing JSON
jQuery PHP
$.ajax({ $url = "example.json";
! url: "example.json", $file_content = file_get_contents($url);
! success: function(data){ $data = json_decode($file_content);
! ! alert(data.string); echo $data->string;
! }
});
- 5. Facebook
graph.facebook.com/cocacola
{
"id": "40796308305",
"name": "Coca-Cola",
"picture": "http://profile.ak.fbcdn.net/hprofile-ak-snc4/276879_40796308305_1578420141_s.jpg",
"link": "https://www.facebook.com/coca-cola",
"likes": 35648837,
"category": "Food/beverages",
"website": "http://www.coca-cola.com",
"username": "coca-cola",
"founded": "1886",
"products": "Coca-Cola is the most popular and biggest-selling soft drink in history […]",
"location":{
"latitude": 42.00736,
"longitude": -72.521224
},
"can_post": true,
"checkins": 73
}
Dateigröße: 1,16 KB
- 6. Facebook – Albums
graph.facebook.com/mercedesbenzdeutschland/albums
{
"data": [
{
"id": "251092158272082",
"from": {
"name": "Mercedes-Benz Deutschland",
"category": "Cars",
"id": "145689658812333"
},
"name": "DTM 2011 - Rennen, Finale und Showprogramm",
"location": "Hockenheimring Baden-Wu00fcrttemberg",
"link": "https://www.facebook.com/album.php?fbid=251092158272082&id=145689658812333&aid=54543",
"cover_photo": "251092214938743",
"count": 10,
"type": "normal",
"created_time": "2011-10-27T08:08:23+0000",
"updated_time": "2011-10-27T08:10:30+0000",
"can_upload": false
},
{
"id": "249480695099895",
"from": {
"name": "Mercedes-Benz Deutschland",
- 7. Facebook – Album Photos
graph.facebook.com/251092158272082/photos
{
"data": [
{
"id": "251092214938743",
"from": {
"name": "Mercedes-Benz Deutschland",
"category": "Cars",
"id": "145689658812333"
},
"tags": {
"data": [
{
"id": "100000441323195",
"name": "Denis Hu00f6rner",
"x": 50.1042,
"y": 83.6795,
"created_time": "2011-10-27T10:40:08+0000"
}
]
},
"name": "DTM 2011rnrnMotorsports / DTM: german touring cars championship 2011, 07 […]",
"picture": "http://photos-f.ak.fbcdn.net/hphotos-ak-snc7/299511_251092214938743_145689658812333_64…",
"source": "http://a6.sphotos.ak.fbcdn.net/hphotos-ak-snc7/s720x720/299511_251092214938743_14568965…",
- 8. Facebook – Picture
graph.facebook.com/251092214938743
{
"id": "251092214938743",
"from": {
"name": "Mercedes-Benz Deutschland",
"category": "Cars",
"id": "145689658812333"
},
"tags": {
! ! […]
},
"name": "DTM 2011rnrnMotorsports / DTM: german touring cars championship 2011, 07 Jamie Green (GBR, AMG
"picture": "http://photos-f.ak.fbcdn.net/hphotos-ak-snc7/299511_251092214938743_145689658812333_642955_10555
"source": "http://a6.sphotos.ak.fbcdn.net/hphotos-ak-snc7/s720x720/299511_251092214938743_145689658812333_64
"height": 505,
"width": 720,
"images": [
{
"height": 505,
"width": 720,
"source": "http://a6.sphotos.ak.fbcdn.net/hphotos-ak-snc7/s720x720/299511_251092214938743_145689658812
},
{
"height": 126,
- 12. Twitter
api.twitter.com/1/statuses/user_timeline.json?screen_name=saschalobo
[
! {
! ! "id": 134979869225402368,
! ! "text": "Keine Ahnung, was das fu00fcr die Finanzkrise hiesse, aber mein Leben wu00e4re
besser, wenn der Begriff "Rating-Riese" verboten wu00fcrde",
! ! "created_at": "Fri Nov 11 13:04:43 +0000 2011",
! ! "user": {
! ! ! "id": 5876652,
! ! ! "name": "Sascha Lobo",
! ! ! "screen_name": "saschalobo"
! ! },
! ! "retweet_count": 9
! },
! {
! ! "id": 134944048069869569,
! ! "text": "u00dcberall liest man 11.11.11 u2013u00a0liebe Nerds, bitte achtet auch im Internet
auf Eure Schriftsprache und schreibt: !!.!!.!!",
! ! "created_at": "Thu Nov 10 22:31:56 +0000 2011",
! ! "user": {
! ! ! "id": 5876652,
! ! ! "name": "Sascha Lobo",
! ! ! "screen_name": "saschalobo"
! ! },
- 15. YouTube
gdata.youtube.com/feeds/api/users/NationalGeographic/uploads?v=2&alt=json&max-results=50
{
! […]
! "entry": [
! ! {
! ! ! "published": {
! ! ! ! "$t": "2011-11-11T20:59:35.000Z"
! ! ! },
! ! ! "updated": {
! ! ! ! "$t": "2011-11-13T18:00:48.000Z"
! ! ! },
! ! ! "title": {
! ! ! ! "$t": "Thrive: How to be Happy Tip #1"
! ! ! },
! ! ! "media$group": {
! ! ! ! "media$thumbnail": [
! ! ! ! ! {
! ! ! ! ! ! "url": "http://i.ytimg.com/vi/gYm0tDcQMI0/default.jpg",
! ! ! ! ! ! "time": "00:00:37.500"
! ! ! ! ! },
! ! ! ! ! {
! ! ! ! ! ! "url": "http://i.ytimg.com/vi/gYm0tDcQMI0/3.jpg",
! ! ! ! ! ! "time": "00:00:56.250"
! ! ! ! ! }
- 16. YouTube – Data API
code.google.com/intl/en-UK/apis/youtube/2.0/reference.html
- 19. Anwendungen
• Mediatheken
Videos von YouTube & Fotos von Facebook verbinden
• Benutzergenerierte Inhalte
Twitterwall, Benutzerbilder von Partygästen