APOD Plugin

  • warning: strlen() expects parameter 1 to be string, array given in /home/ebeyrent/public_html/includes/bootstrap.inc on line 774.
  • warning: htmlspecialchars() expects parameter 1 to be string, array given in /home/ebeyrent/public_html/includes/bootstrap.inc on line 741.
  • warning: strlen() expects parameter 1 to be string, array given in /home/ebeyrent/public_html/includes/bootstrap.inc on line 774.
  • warning: htmlspecialchars() expects parameter 1 to be string, array given in /home/ebeyrent/public_html/includes/bootstrap.inc on line 741.

A friend of mine wanted to start his own blog, and as a major astronomy buff, he picked out the Red Planet theme. I thought a nice touch would be to add the Astronomy Picture of the Day widget to his sidebar.  However, nothing is ever as easy as it seems. The plugin failed, because url file access was disabled in the php.ini configuration on the webhost. I attempted to change this using the ini_set() function, but was unsuccessful. Not willing to give up, I rewrote a large portion of the widget that retrieves the APOD content to use cURL instead. In a nutshell, the widget uses cURL to read the APOD page for the current day. There are two images in the page - a small version and a large version. The source of both images is parsed from the captured html, and cURL is used again to fetch the image data for the small image. Because of the security settings, I couldn't do a getimagesize() call against the image URL directly, so I had to write the image data to a temp file first, and then I was able to get the dimensions of the image to resize it to fit within the sidebar.

Trackback URL for this post:

http://beyrent.net/trackback/78

About Erich

Erich is a web developer and a native New Englander who is passionate about life, the universe, and everything.

He is a Drupal consultant, previously employed as a senior developer at Harvard University, working on the IQSS OpenScholar project.  Prior to joining the team at Harvard, he was the engineering manager at CommonPlaces e-Solutions, in Hampstead, NH, contributing as the lead engineer on the Greenopolis.com and Twolia.com.

Erich is active in the Drupal community, having contributed modules and patches to the community. He presented at DrupalCon in Szeged Hungary, and co-presented at DrupalCon 2009 in Washington, DC.

Erich lives in New Hampshire with his wife, two sons, and three weimaraners.  When not writing code, Erich enjoys landscaping and woodworking.

Faceted search

Categories

Content type

Project types

Artwork Type

Artwork Tags

Recent comments

Activity Stream

August 29, 2011

August 25, 2011

August 24, 2011

August 23, 2011

August 15, 2011

August 11, 2011

August 10, 2011

August 9, 2011

August 4, 2011

August 3, 2011