I use cfPicasa, by Charles Toro, on one of my websites to connect to my Google Picasa web albums. A couple of weeks ago, it stopped working for me. The albums listed fine, but when you would go into the album, you would get a " Element PHOTO:IMGSRC is undefined in a Java object of type class coldfusion.xml.XmlNodeList" error.
I looked into the error more and it seems that Google updated their RSS structures in the feeds for the album details. Anyways, its a pretty quick fix, so here is what you have to do to make it work again:
Change the getAlbumXML function in cfPicasa.cfc from this:
<cffunction name="getAlbumXML" access="public" output="false" hint="This parses then queries your album XML.">
<!--- Grab passed variable and fetch RSS link --->
<cfargument name="rsslink" type="string" required="yes">
<cfset variables.picasaURL["album"] = toString(toBinary(arguments.rsslink))>
<cfhttp url="#variables.picasaURL["album"]#"
method="GET"
timeout="15">
</cfhttp>
<!--- Now lets parse the XML file --->
<cfset albumXML = trim(cfhttp.filecontent)>
<cfset albumXML = XMLparse(albumXML)>
<!--- Create a query and loop the results --->
<cfset qAlbum = QueryNew("photo_imgsrc,photo_thumbnail")>
<cfset queryAddRow(qAlbum, ArrayLen(albumXML.rss.channel.item))>
<cfloop from="1" to="#ArrayLen(albumXML.rss.channel.item)#" index="i">
<cfloop from="1" to="#listLen(qAlbum.columnList)#" index="n">
<cfset querySetCell(qAlbum, listGetAt(qAlbum.columnList, n), albumXML.rss.channel.item[i][listGetAt(ReplaceList("#qAlbum.columnList#", "_", ":"), n)].XMLText, i)>
</cfloop>
</cfloop>
<!--- Time to query the query --->
<cfquery name="rqAlbum" dbtype="query">
SELECT *
FROM qAlbum
</cfquery>
<cfreturn rqAlbum>
</cffunction>
To this:
<cffunction name="getAlbumXML" access="public" output="true" hint="This parses then queries your album XML.">
<!--- Grab passed variable and fetch RSS link --->
<cfargument name="rsslink" type="string" required="yes">
<cfset variables.picasaURL["album"] = toString(toBinary(arguments.rsslink))>
<cfhttp url="#variables.picasaURL["album"]#"
method="GET"
timeout="15">
</cfhttp>
<!--- Now lets parse the XML file --->
<cfset albumXML = trim(cfhttp.filecontent)>
<cfset albumXML = XMLparse(albumXML)>
<!--- Create a query and loop the results --->
<cfset qAlbum = QueryNew("media_content,media_thumbnail")>
<cfset queryAddRow(qAlbum, ArrayLen(albumXML.rss.channel.item))>
<cfloop from="1" to="#ArrayLen(albumXML.rss.channel.item)#" index="i">
<cfloop from="1" to="#listLen(qAlbum.columnList)#" index="n">
<cfset querySetCell(qAlbum, listGetAt(qAlbum.columnList, n), albumXML.rss.channel.item[i]["media:group"][listGetAt(ReplaceList("#qAlbum.columnList#", "_", ":"), n)].XmlAttributes.url, i)>
</cfloop>
</cfloop>
<!--- Time to query the query --->
<cfquery name="rqAlbum" dbtype="query">
SELECT *
FROM qAlbum
</cfquery>
<cfreturn rqAlbum>
</cffunction>
What i did was change what qAlbum is set to as well as change the element structure when setting the querySetCell code. You have to add the "media:group" element to get things going again... Make sure you change your display code from #photo_imgsrc# and #photo_thumbnail# to #media_content# and #media_thumbnail# respectively.
Let me know if you have any questions!
Recent Comments