Home › Forums › Other › Retrieving, understanding and displaying a JSON feed on my site. (advice needed!)
- This topic is empty.
-
AuthorPosts
-
August 25, 2012 at 8:12 pm #39516
staticwaves
Memberdo you have any suggestions on how i can learn to retrieve a JSON event listing feed, convert the language and display in my own style?
Are templates available?
I need to learn what each code document i need and what they do.
I have seen many tutorials, but they are all very advanced and don’t explain the big picture.August 26, 2012 at 4:03 am #108477staticwaves
MemberHey Traq, thanks for looking in to this.
I need to retrieve the data from ticketfly.com – basically i need to list events like they have on their site, but with my own styling. I will have the following feeds:
upcoming events, single event, featured event and just announced events.August 26, 2012 at 1:11 pm #108482TheDoc
MemberMy only experience is using jQuery for this, but I think it looks *very* similar in PHP.
I’ll give you an example of some code I use for Twitter’s API:
$.ajax({
url: 'https://api.twitter.com/1/statuses/user_timeline.json?screen_name=[twitterUserName]&count=20&callback=?&include_rts=true',
dataType: 'jsonp',
success: function(data) {
// do something with the data
// to see what the data is returning, you can log it to the console
// by going console.log(data);
},
error: function() {
// something is borked - display an error message
}
});So you would replace [twitterUserName] with a username and you’d return a bunch of information in a file that looks like: https://api.twitter.com/1/statuses/user_timeline.json?screen_name=graygilmore&count=20&callback=?&include_rts=true
It might look all jumbled, but that’s just because the browser is putting it all together on one line. If you take that data and paste it into here: http://jsbeautifier.org/ you’ll see that it’s actually neatly sorted.
So let’s say we wanted to get some information from that call. Let’s try to find out how many people I’m following. Inside our success function I would do something like this:
var following = data[0].user.friends_count
We’re just following the chain of where that information lives. First object in the Data array > User > Friends Count. It’s pretty simple, really!
If we wanted to do something different for each tweet, we could do something like this:
$.each(data, function() {
// do something with each tweet
});August 27, 2012 at 3:48 pm #108546staticwaves
MemberThanks for the info Doc.
Traq – i do have all of the documentation for the ticketfly api. I just dont know what to do with it yet.
I am very new at this and really dont know what documents i need and where to put them in my wordpress site. I do have all of the correct request codes and and can pull up the feed in a browser.. just cannot figure out how to integrate it in my site.
August 27, 2012 at 10:52 pm #108576staticwaves
Memberi guess i need to take javascript tutorials??
August 28, 2012 at 12:12 am #108579staticwaves
Membergotcha. it is my understanding that wordpress is php.. am i correct?
if so, php it is. i know basics of HTML and CSS -thats about it. I am working on learning PHP and Javascript, but those both seem like a steep climb. What language would you guys recommend?
It would be a dream to be able to find a plugin for this.August 29, 2012 at 2:17 pm #108699staticwaves
MemberProbably front end stuff. I think we should go with javascript for now. Is TheDoc’s example the only file that i would have to add? I assumed that i need a few different files to make this happen.
August 30, 2012 at 1:13 am #108744wehk
MemberMaybe you can go for the language you are familiar with. For example, if you are good at php, you may convert the JSON to array and do whatever you like in php and then add whatever deisgn elements to it.
August 30, 2012 at 11:55 pm #108792staticwaves
MemberCool! thanks for all of the advice Traq. I will get started on learning Javascript. As soon as i get started on the code for this api, ill let you know! again, i really appreciate the help!
August 31, 2012 at 1:44 pm #108828TheDoc
MemberI remember starting out dealing with APIs and feeling totally overwhelmed. Everything was confusing and even if I did get the result that I wanted I was never quite sure how it worked (too much copying and pasting from other resources).
But eventually you have to tinker with it enough that you start to understand what’s going on. The next thing you know you’re building themes that actually rely on using some pretty complicated APIs!
September 2, 2012 at 2:18 pm #108929staticwaves
Memberhaha, so its not just overwhelming only to me! The main reason that it is overwhelming is that i do not see a clear route to learning it. I have not been able to find (maybe from not knowing the lingo) a tutorial that is easy to follow.
I seem to be spending hours looking for the right one. I started the tutorial on Javascript at w3schools, but that seems more like a reference than a step by step learning process. Do you suggest any solid free tutorials? At this point in time, i cannot afford a paid tutorial. -
AuthorPosts
- The forum ‘Other’ is closed to new topics and replies.