Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

CFHTTP and Caching

New Here ,
Dec 19, 2007 Dec 19, 2007
I have tried the following where it should cache the RSS feed in the application.cfm page every 20 minutes but I am getting the error

Error Occurred While Processing Request Element TIMESTAMP is undefined in APPLICATION.

Any ideas on why I am getting this error ?

---
In my application.cfm

<CFIF (APPLICATION.TimeStamp EQ "") OR (DateDiff("n", APPLICATION.TimeStamp, TimeFormat(NOW(), "hh:mm:s")) GT 20)> <CFSET APPLICATION.TimeStamp = CreateTime(TimeFormat(NOW(), "hh"), TimeFormat(NOW(), "mm"), TimeFormat(NOW(), "s"))>

<CFSET APPLICATION.weather_xml =XMLParse(cfhttp.FileContent)>
<cfhttp url=" http://feeds.bbc.co.uk/weather/feeds/rss/5day/world/0008.xml" method="GET" resolveurl="No"></cfhttp>
</CFIF>

In my display page I have the following code

<cfoutput>
<img src="#application.weather_xml.rss.channel.image.url.xmlText#" alt="#application.weather_xml.rss.channel.item.DESCRIPTION.xmlText#">


<cfloop index="x" from="1" to="#ArrayLen(application.weather_xml.rss.channel.item)#">

<br>
#replace(application.weather_xml.rss.channel.item.title.xmlText, ',', '<br>', 'ALL')# <br>


</cfloop>
</cfoutput>

1.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Dec 19, 2007 Dec 19, 2007
Hi,

I think you can not use 'Timestamp' as a Application variable since it is a reserved keyword.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 19, 2007 Dec 19, 2007
Any ideas on what I can use to achieve this instead of timestamp ?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Dec 19, 2007 Dec 19, 2007
Hi,

Eventhough it is a reserved keyword, There seems no variable intialization for the 'Application.TimeStamp' variable in your Application.cfm file.

Are you setting (or) intializing it with any values before putting it in your conditional statements?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 19, 2007 Dec 19, 2007
No how would I put this in ? what do I need to add to initialize it ?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Dec 19, 2007 Dec 19, 2007
Hi,

In your Application.cfm file set it like,

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 19, 2007 Dec 19, 2007
That seems to have got rid of one error, I am now getting

Element WEATHER_XML.RSS is undefined in APPLICATION.

The error occurred in \weather2.cfm: line 6
4 : <body>
5 :
6 : <cfdump var="#application.weather_xml.rss#">


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Dec 19, 2007 Dec 19, 2007
Hi,

Change your <cfdump> statement to,

<cfdump var="#application.weather_xml#"> and then look out for them elements you need to output.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 19, 2007 Dec 19, 2007
changed my cfdump statement, I am now getting the error below even though I have defined this in my application.cfm page

Element WEATHER_XML is undefined in APPLICATION.

Application.cfm page

--
<cfset Application.TimeStamp="#TimeFormat(now(), 'hh:mm:ss')#">

<CFIF (APPLICATION.TimeStamp EQ "") OR (DateDiff("n", APPLICATION.TimeStamp, TimeFormat(NOW(), "hh:mm:s")) GT 20)>

<CFSET APPLICATION.TimeStamp = CreateTime(TimeFormat(NOW(), "hh"), TimeFormat(NOW(), "mm"), TimeFormat(NOW(), "s"))>

<cfhttp url=" http://feeds.bbc.co.uk/weather/feeds/rss/5day/id/3314.xml" method="GET" resolveurl="No"></cfhttp>
<CFSET APPLICATION.weather_xml =XMLParse(cfhttp.FileContent)>

</CFIF>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Dec 20, 2007 Dec 20, 2007
Hi,

I think there might be some issues with your feed retrieval. Check whether you are able to pull data through cfhttp (using a temporary cfm file rather than your current 'Application.cfm' file).
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 20, 2007 Dec 20, 2007
The feed retrieval is ok using a .cfm file, the problem is when I try to cache the results of this feed into the application.cfm page.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 21, 2007 Dec 21, 2007
well, maybe you can retrieve the feed with that code, but i sure could
not... i get connection failure all the time...

---
Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 21, 2007 Dec 21, 2007
this works for me

<cfhttp url=" http://feeds.bbc.co.uk/weather/feeds/rss/5day/id/3314.xml" method="GET" resolveurl="No"></cfhttp>
<CFSET APPLICATION.weather_xml =XMLParse(cfhttp.FileContent)>

<cfdump var="#APPLICATION.weather_xml#">

But I need to get this feed cached (every 3 hours) in the application.cfm page so the feed does not go out to the internet every time
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 23, 2007 Dec 23, 2007
LATEST
well, maybe that bbc service is not available internationally... i still
get only "Connection Failure" response from here in Laos...

---
Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources