Charl van Niekerk » Blog

Main

Latest

Archives

Powered by Blogger

Gnip API Changes

About three days ago, gnip decided to change their API, apparently without sending an e-mail to their (consumer) developers. The publisher.name attribute has been renamed to type and the twitter value has been changed to tweet. identica remains the same.

This broke the CLUG Micropark and I had to fix. Managed to come up with the following solution after some debugging. This has been checked into starstar with revision 5.

Index: update.php
===================================================================
--- update.php (revision 3)
+++ update.php (working copy)
@@ -33,7 +33,10 @@
 $data = file_get_contents('php://input');
 $xml = new SimpleXMLElement($data);
 foreach ($xml->activity as $activity) {
- $service = $activity['publisher.name'];
+ $service = $activity['type'];
+ if ($service == 'tweet') {
+  $service = 'twitter';
+ }
  $post_author_name = $activity['uid'];
  $post_author_uri = getAuthorUri($post_author_name);
  $post_date = date('Y-m-d H:i:s', strtotime($activity['at']));

But, why?

2 Comments

Comment by Blogger Jud on Wednesday, September 10, 2008 5:07:00 PM

Our deepest apologies. This was inadvertent. I've posted about it here http://groups.google.com/group/gnip-community/browse_thread/thread/e72371be4cc88f3b

Two things:
1 - you've worked around the issue in a reasonable manner given the rest of your code (as visible in the diff).
2 - it's probably a little sketchy to derive "service" from the "type" field. "Type" is the type of activity, while publisher.name was the actual "service." Please checkout the post I reference above for Publisher/service derivation going forward.

Again... please accept our apologies here; our mistake.

- Gnip Team

Comment by Blogger Charl van Niekerk on Wednesday, September 10, 2008 11:29:00 PM

Hi Jud,

Many thanks for your comment, much appreciated.

After reviewing your post, the change is making perfect sense to me and I support it. I commented directly on your post with my further thoughts.

Best Regards,
Charl

Post a Comment

Copyright © 2004-2009 Charl van Niekerk. All articles are released under the Creative Commons Attribution 2.5 South Africa licence, unless where otherwise stated.