Showing posts with label Programming. Show all posts
Showing posts with label Programming. Show all posts

Mar 17, 2010

Parsing JSON response with PHP

We are currently trying to tie in the Yelp API into our group project so I thought I would post what we have learned in trying to parse the JSON response. Since JSON is the only response method that Yelp offers, it was imperative that we figure it out. First, the proxy part is the same, meaning that I obtained the response the same way that I did with all of my XML responses. To do this I use this but of code:




After that I use the json_decode() function to convert the data into a searchable format:


NOTE: One nice trick that I learned is to do a var_dump() of the data variable to your output destination. What this does is essentially show you the structure of the JSON response so that you can see the hierarchy of tags. This is similar to just putting your XML URL into firefox in order to see the layout. To do this I use the following snippet of code:



The output will look like this:



After that it is just a matter of figuring out which items you want to retrieve and then grabbing that information. Yelp puts everything under the heading of businesses, which means that I use the following code to access the elements:



So here is the output on the site:


Feb 24, 2010

Picture-driven computing

“Sikuli is a visual technology to search and automate graphical user interfaces (GUI) using images (screenshots).”
What does this mean, well it is a really neat technology developed by MIT. Instead of programming using 100% code, imagine if you could say “find on the page (this item), focus (here), and click (here)” all using screenshot clips instead of coding the name of each entity.



I haven’t had time to download it and try it yet, although I definitely would make the time if it could help the project. It seems like it would be something that could help one understand the concept of what we are doing.

Picture computing is really a neat concept that is exciting as well as worrisome. Saw this site a while ago and was amazed. However after thinking about it a while I realized that this is kind what I’m going to school for. If this catches on after awhile, people won’t be paying others to do something that everyone can do.

Feb 3, 2010

Milestone 1

Today is the day of Milestone 1. Its a day where I worry did I do it correctly? Do I have enough information? I keep going back to the phrase that professor used in class that this milestone should be light. Light is not the correct word, but I can't remember the correct phrasing right now.

Did I run into problems? That is the "joy" of programming. You run into a problem and then you try and fix it. One thing that I tried to do this time was have an idea in my head exactly what I want to do. A lot of times i just jump into what I am doing and then I sink because I don't know what to do.

I finished chapter 1 and 2 before I started my individual application. I was reading a lot of the blogs and it seemed like everyone was trying to jump into their individual project. I agree because of deadlines you have have to make adjustments to your schedule. So, if you are running out of time, then you need to work on what is due. I just can't stress enough, that going through the application in the text book will help.

Problem that has come up with me doing a lot of testing of my individual project. I have gotten my application to work correctly and do exactly what I pictured in my head. The one thing I have noticed and having a hard time fixing is getting my application to work on internet explorer. It works just as planned on firefox. I know you need to have some different code for each browser. This is something I would like to fix hopefully before it is time to turn it in.

Jan 17, 2010

Head First Ajax

Ok, so I bought the Head First Ajax book this weekend and thought that I would look through it to get an idea of some of the material that we will be covering. I had talked to several people (Three to be exact) who had this class last term that said that the book was, to be blunt, a POS. Being fairly open minded I thought I would get it in order to form my own opinion. Well after spending $45.00 I initially concur with my classmates reviews.

I come from a programming background. I currently know Perl, C++, C#, VB Script, HTML, some JavaScript, some Java, and enough PHP to be dangerous. For the most part I'm self taught, having had one C# class and a couple C++ classes, I was able to get enough of the basics to do some substantial development out of the classroom. One thing I like in a programming books is a logical format that provides a lot of examples and code for me to analyze and assess. After opening the Head First book the only thing I can focus on is the pictures...lots and lots of pictures, followed by an illogical and hard to follow structure.

I read some of the reviews by other buyers on the amazon site (Amazon) and by in large, most of the reviews are very positive. With the exception of a lot of people talking about editing problems and the author showing examples that are not possible (1 Star reviews), most people find the book useful( 5 Star reviews). One of the interesting quotes that I saw in the 1 star reviews section was that "This book is not for the person learning on their own" by user I.M. There. While we are learning this in a classroom environment, my guess is that as with any programming class, we will be learning and stumbling through this topic on our own outside the class room.

I'll conclude with this. I will continue to explore this book with an open mind and try to leave my analytic brain somewhere else when I crack the book open. Most people in their reviews have stated that while this book is probably not designed for an engineering type of mindset, it does present the material in a easy to understand format as well as a reinforcing style. So I will try to do my best to use the book and I will provide an update to this blog as I progress through the class to see if my initial assessment has changed.