Copy link to clipboard
Copied
Hi,
I am using the cffeed to read from my twitter RSS feed but I get this error:
Unable to read the source URL.
Status Code: 400. Try adding or changing UserAgent attribute in the CFFeed tag
My code is:
<cfset feedurl="http://twitter.com/statuses/user_timeline/somenumbers.atom" />
<cffeed
source="#feedurl#"
properties="feedmeta"
query="feeditems1" overwrite="true" />
It works but suddenly it stops and it takes time about 15 minutes or more to work again.
Can any body help me with this?
Thanks,
Mandana
Copy link to clipboard
Copied
Did you try what the error message suggested?
--
Adam
Copy link to clipboard
Copied
I tried this one which is useragent attribute:
<cffeed
source="#feedurl#"
properties="feedmeta"
query="feeditems1" overwrite="true"
useragent="Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.2; WOW64; Trident/4.0; GTB6.6; InfoPath.2; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; AskTbBLPV5/5.11.3.15590)" />
I found the user agent by this : cfdump #cgi.http_user_agent# and copy/paste it in useragent attribute but still does not work.
Copy link to clipboard
Copied
I'm not sure what to suggest. It might be something coming through the feed which CF doesn't like. Modify your code with a try/catch and if it errors, do a CFHTTP on the URL instead, and have a look @ what it's returning: see if there's anything that CFFEED wouldn't like (like malformed XML).
--
Adam
Copy link to clipboard
Copied
I tried it with cfhttp in cfcatch and I got the error of 'malformed XML'
I read something about twitter rate limiting( http://dev.twitter.com/pages/rate-limiting#rest).It says: Anonymous calls are based on the IP of the host and are permitted 150 requests per hour. This classification includes unauthenticated requests (such as RSS feeds), and authenticated requests to resources that do not require authentication.
Do you think this is the problem?
Copy link to clipboard
Copied
I tried it with cfhttp in cfcatch and I got the error of 'malformed XML'
What gave the "malformed XML"? Was that all that was in the filecontent of the CFHTTP result? That seems unlikely. What came back from Twitter in response to your request? Don't parse it or process it or anything, just look at it. What does it say?
--
Adam
Copy link to clipboard
Copied
This is my code:
<cfset tempDir=GetTempDirectory()>
<cfset tempFile = GetTempFile(tempDir, "myfeed")>
<cfset tempFileName = GetFileInfo(tempFile).name>
<cfhttp url="#feedurl#" path="#tempDir#" file="#tempFileName#">
<cfhttpparam type="header" name="Accept-Encoding" value="compress,gzip,deflate">
</cfhttp>
<cffeed action="read" source="#tempFile#" name="feeditems1" >
and I got this error:
Copy link to clipboard
Copied
One thing which I did not mentioned is I want to have 6 pages rss feed together and I made it like this:
<cffeed
source="#feedurl1#"
properties="feedmeta"
query="feeditems1" overwrite="true"
useragent="Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.2; WOW64; Trident/4.0; GTB6.6; InfoPath.2; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; AskTbBLPV5/5.11.3.15590)" />
<cffeed
source="#feedurl2#"
properties="feedmeta"
query="feeditems2" overwrite="true"
useragent="Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.2; WOW64; Trident/4.0; GTB6.6; InfoPath.2; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; AskTbBLPV5/5.11.3.15590)"/>
.
.
.
I did it for 6 pages, each one with one cffeed and then:
<cfquery name="feeditemstotal" dbtype="query">
select * from feeditems1
union
select * from feeditems2
union
select * from feeditems3
union
select * from feeditems4
union
select * from feeditems5
union
select * from feeditems6
</cfquery>
Copy link to clipboard
Copied
Here's some pseudocode of the logic you need to try
TRY
CFFEED [the url]
CATCH
CFHTTP [the url]
DUMP CHTTP <--- what does this bit output
ABORT
/CATCH
/TRY
--
Adam
Copy link to clipboard
Copied
OK, with cfhttp and dump t
here is no error but how I can get the cfhttp in a query?
Copy link to clipboard
Copied
This is just a troubleshooting step, not a suggested solution.
All I want to know is what the blimin' HTTP response from Twitter says, when it fails to send back the RSS feed. Is that too much to ask?
--
Adam
Copy link to clipboard
Copied
If I understand what you meant:
I got this message in cfdum filecontent:
<?xml version="1.0" encoding="UTF-8"?> <hash> <request>/statuses/user_timeline/34727375.atom</request> <error>Rate limit exceeded. Clients may not make more than 150 requests per hour.</error> </hash>
Its rate limit in twitter as I thought.
Thanks for your help
Copy link to clipboard
Copied
No problem.
So you need to adjust your code to perhaps not re-get the feed every request. What you could do is set up some sort of task to get it every 5min or so, stick the results in a variable (which scope it goes it is up to what makes sense for the app), and then just use that variable for whatever it is you're displaying. Sorry to sound vague, I don't use Twitter (and to be frank: don't understand why anyone would: isn't the world banal enough as it is without everyone demonstrating that to be true in 140-char slices, every time the patheticness of their existence occurs to them? Ahem. Sorry). Or you could write it to a local file every 5min, or something. But the point is: don't bang away @ Twitter every request or you'll get blocked.
--
Adam
Copy link to clipboard
Copied
Thanks Adam.
I do not like twitter either. It's a project at work.
Thanks for the time you put into this,
Mandana