Jump to content

Doing something with JSON


mykmallett

Recommended Posts

I cannot for the life of me figure out how to do anything with the JSON file that Facebook events give to me

 

I have this AJAX:

$.getJSON("getevent.php?event="+event,function(data)
{
var items = [];

  $.each(data, function(key, val) {
    items.push('<li id="' + key + '">' + val + '</li>');
  });

  $('<ul/>', {
    'class': 'my-new-list',
    html: items.join('')
  }).appendTo('body');
}

 

Which passes a Facebook events URL that the user enters to this PHP

 

$url = $_GET['event'];

parse_str( parse_url( $url, PHP_URL_QUERY ) );
$id = $eid;


$url = 'https://graph.facebook.com/'.$id;

$json = file_get_contents($url,0,null,null);
$json_output = json_decode($json, true);


echo $json

 

 

Which would output json like this:

 

{
   "id": "331218348435",
   "owner": {
      "name": "Julia Lam",
      "id": "2503747"
   },
   "name": "Facebook Developer Garage Austin - SXSW Edition",
   "description": "Join the Facebook team and local developers for a deep dive into the latest and most exciting ways developers are building with Facebook technologies.  \n\nCome to learn, stay to make friends!\n\nTentative Agenda:\n2:00 - 2:30 PM - Registration\n2:30 - 3:30 PM - Learn the latest from Facebook and local developers\n3:30 - 5:30 PM - Drink with friends!  Stay and mingle with your developer community.\n\n*Come early!  Drink tickets and t-shirts provided to the first 300 attendees.  Cash bar provided for all attendees.\n\nTopics & Speakers:\n--Multi-Platform Social Games (Gareth Davis, Facebook) \n--Increasing Mobile Engagement with Facebook Connect (Josh Williams, Gowalla)\n--Facebook Integration with Seesmic (or How to Build Community Using Octopus Balls...) (John Yamasaki, Seesmic)\n--Going multi-platform: the brave new world beyond facebook.com (Sebastien de Halleux, Playfish / EA Interactive)\n--Socially Connected Exploding Gems Everywhere...Excellent! (Jon David, PopCap Games)\n\n* Emceed by Austin local: whurley, Chaotic Moon Studios\n* All are welcome to attend, no badge is required.\n* If you can't make it in person, you can join the live stream, beginning at 2:00 PM CST, here: http://ustream.tv/fbplatform  \n\n***DAYLIGHT SAVINGS STARTS SUNDAY AT 2 AM, PLEASE ADJUST YOUR CLOCKS ACCORDINGLY***",
   "start_time": "2010-03-14T14:00:00",
   "end_time": "2010-03-14T17:30:00",
   "location": "The Phoenix",
   "venue": {
      "street": "409 Colorado St.",
      "city": "Austin",
      "state": "Texas",
      "country": "United States",
      "latitude": 30.2669,
      "longitude": -97.7428
   },
   "privacy": "OPEN",
   "updated_time": "2010-04-13T15:29:40+0000"
}

 

 

Its all working fine up until it is supposed to do something with the JSON. Firebug is saying it is recieving the JSON return fine. What I would like to eventually do with it is assign each part to a variable for later use, but I just cannot figure out what to do with it. Can anyone help, I have been reading conflicting tutorials and examples on ajax for days now.

 

Thanks

Mike

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.