Tag: XML

Thursday Quote: Phil Wadler

July 5, 2012 » Geek

“The essence of XML is this: the problem it solves is not hard, prescription and it does not solve the problem well.”

– Phil Wadler
POPL 2003

Tags: ,

Use xmllint to Pretty Print API Output

June 10, 2010 » Geek

I’ve been messing with the Foursquare API and I was getting frustrated by it’s unreadable output. Too much XML, not enough whitespace!

[email protected]:~$ curl -l http://api.foursquare.com/v1/venues?geolat=41.243385\&geolong=-96.017697

170922Peter Kiewit Institute79037College & Education:UniversityUniversityhttp://foursquare.com/img/categories/education/default.png
1110 South 67th Street
at Pacific StOmahaNE6818241.2436984-96.014670204025543333PKI255
345883Liv Lounge79168Nightlife:LoungeLoungehttp://foursquare.com/img/categories/nightlife/lounge.png
2279 S 67th St
at Center StOmahaNebraska6810641.2436984-96.01467020255
245578Walmart79221Shops:Department StoreDepartment Storehttp://foursquare.com/img/categories/shops/default.png
1606 S 72nd St
at Pine StOmahaNE6812441.2440158-96.024115804023939560541
254875Aksarben Village79196Parks & Outdoors:Plaza / SquarePlaza / Squarehttp://foursquare.com/img/categories/parks_outdoors/default.png
6600 Shirley St
at Center StOmahaNE6810641.2414632-96.01205190518
170916Scott Technology Center79115Home / Work / Other:Corporate / OfficeCorporate / Officehttp://foursquare.com/img/categories/building/default.png
6825 Pine Street
2468550Juice Stop79071Food:Juice BarJuice Barhttp://foursquare.com/img/categories/food/default.png
2119 S 67th St
Shirley StOmahaNE6810641.2403021-96.014660704029343870427
199022Scott Conference Center96353Home / Work / Other:Event SpaceEvent Spacehttp://foursquare.com/img/categories/building/default.png
6450 Pine Street
772128Courtyard Aksarben VIllage79273Travel:HotelHotelhttp://foursquare.com/img/categories/travel/hotel.png
1625 S 67th St
at Pine StOmahaNE6810641.243304-96.01434904029514300280
247344Wohlner's Market96359Shops:Food & Drink:GourmetGourmethttp://foursquare.com/img/categories/shops/default.png
2289 S 67th St
at Center StOmahaNE6810641.23806024488222-96.013898849487304025516875672
2564306First Data79115Home / Work / Other:Corporate / OfficeCorporate / Officehttp://foursquare.com/img/categories/building/default.png
6855 Pacific Street
[email protected]:~$

How can we rectify this situation? xmllint! This is part of libxml and should exist on most systems.

[email protected]:~$ curl -l http://api.foursquare.com/v1/venues?geolat=41.243385\&geolong=-96.017697 | xmllint --format -
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
101  5265  101  5265    0     0  13778      0 --:--:-- --:--:-- --:--:-- 29914

      Peter Kiewit Institute
        College & Education:University
1110 South 67th Street
at Pacific St Omaha NE 68182 41.2436984 -96.0146702 0 4025543333 PKI 255
... snip ... 2564306 First Data 79115 Home / Work / Other:Corporate / Office Corporate / Office http://foursquare.com/img/categories/building/default.png
6855 Pacific Street
Omaha NE 68106 41.2487029 -96.0192553 0 606
[email protected]:~$

So there you go, a handy trick of the day for you.
In case you missed it the short form is:
curl -l [url] | xmllint --format -

XML, XSL Are Stinkin Powerfull

March 21, 2007 » Geek

I had never really tried to do anything with XML. Looking at an XML file with no help is an intimidating prospect. I figured it was too complicated to bother with, and it’s just for storing things right?

In my file structures class we’ve gotten to XML recently, and today I did my homework for that section. Holy cow is XML cool when you combine it with XSL. The ability to translate a plain XML doc into some nice, clean, formatted XHTML, or really pretty much anything you want is pretty cool. Now I understand.

Tags: ,

Facebook API’s

September 7, 2006 » Geek

This article is in response to a Facebook posting about Facebook “selling” personal information through their developers section. I originally tried to post this on facebook, but it has restrictive message limits, so here it is in it’s entirety. (Pardon the spelling and such, I wrote this is in a rush.)

This is the posting I found on the Facebook site, verbatim:

With all the new changes, Facebook has adopted a “Facebook Development Platform.” Basically, it allows Facebook Inc. to sell any information on you to anyone. This includes your picture, hometown, current location, interests, political views, musical preferences, relationship status, etc. Pretty much anything that you enter on Facebook is sold. The best part is that you are AUTOMATICALLY ENROLLED! They didn’t even tell us! I’m pretty sure Facebook thought they could get away with nobody noticing it since everyone is so overloaded with this new news feed/mini feed junk. If you don’t believe me, check it out for yourself in the Facebook Terms of Service. It’s black and white.So screw them, to remove yourself from the “Facebook Development Platform” follow these instructions:1. Log in to facebook.
2. Click “My Privacy” on the left edge of the window.
3. Under the network, “Everyone” click “edit settings”
3. Scroll to the bottom of the page to the heading “Facebook Development Platform” and uncheck the statement that says “My information may be used according to the restricted Terms of Service.”
4. Click Save.
5. You have official thwarted facebook from whoring out your personal info to the highest bidder!Spread the news! Tell your friends to remove their name from the selling block. This is utterly disgusting!

First of all, they aren’t selling the information, they are exposing web services. What that means is that they’ve realeased API’s to let developers write applications to extend Facebook. The developers can’t access information about you unless you log in to the application they developed. Additionally all information passess through http://api.facebook.com/, which means the developers don’t have direct acess to your passwords, so they aren’t going to steal your account information that way.

Anyone seeking to develop an application has to apply for an API key, which doesn’t cost anything, but can uniquely identify, and allow for the immediate disabling of any application written to steal data.

From the Facebook API FAQ:
“Any content delivered to the outside application can be safely displayed to the user. However, in general, content delievered when using a session key should only be stored until that session key expires, or twelve hours, whichever comes later. The exceptions to this are user ids and affiliations information. This is detailed further in the accompanying documentation.”

The opening of these API’s and web services are a contribution to the Facebook society, and something they’re doing for free. Open source programming is a great benefit to end users, and these API’s and those of other sites allow the creation of rich, dynamic and integrated web applications.

If people take the time to read and understand whats going on with the system they can see that there is noting to “be afraid” of, and that their information is just as secure as ever. Which, I’ll admit, isn’t saying much. Social networking systems such as Facebook are hugely complex systems, and Facebooks should be applauded on their content control systems. They’ve added a at least a mediocum of security to the information on their system with a complex network of “friend” relationships. Compared to other sites, Myspace for example, the security of your information inside of Facebook is commendable.
That leads to the final argument here. Even though Facebook is releasing these API’s (which are a good thing) it’s all still in your control. As the post that first sparked this response says, you can opt out. And barring that Facebook, like other web services such as Flickr, Myspace, etc. is an opt-in. You signed up, if you don’t like it that much, unsubscribe.

I apologize if this was even slightly emotionally charged, I just don’t want to see a good thing ruined because of illogical fears.

Here are some links to help understand whats actually going on.

And here are some example applications built on the API.

Please read and consider these. If you find a posting on Facebook that goes against the new web services, post a link to this site! We could potentially lose a great number of wonderfull social services provided by clever programmers and the Facebook API’s!

Last.fm Web Services

August 29, 2006 » Geek

Huzzah! I was looking around the audioscrobbler.net web services and found my holy grail!

I’ve tried a bunch of ways to retrieve a cover for the most recent track.  I’ve never been able to figure out Amazon’s image naming system, though I found neat hacks at this cool site: http://aaugh.com/imageabuse.html that absorbed way too much time.  I’ve also tried retrieving Google results and regex’ing the whole file, which was slow and rarely worked.

Well, today I found the artist info XML at audioscrobbler. Example
I’m going to incorporate this bad boy into my last.fm scripts and put the system up here on the homepage.  Maybe I’ll try my hand at a WP plugin, just for the heck of it.

Tags: ,