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

Unable to read the source URL error for cffeed

Guest
Apr 14, 2011 Apr 14, 2011

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

3.8K
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 ,
Apr 15, 2011 Apr 15, 2011

Did you try what the error message suggested?

--

Adam

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
Guest
Apr 15, 2011 Apr 15, 2011

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.

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 ,
Apr 17, 2011 Apr 17, 2011

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

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
Guest
Apr 18, 2011 Apr 18, 2011

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?

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 ,
Apr 18, 2011 Apr 18, 2011
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

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
Guest
Apr 18, 2011 Apr 18, 2011

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:

Unable to parse the feed: Either source specified is invalid or feed is malformed.

Error: Invalid XML

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
Guest
Apr 18, 2011 Apr 18, 2011

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>

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 ,
Apr 18, 2011 Apr 18, 2011

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

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
Guest
Apr 18, 2011 Apr 18, 2011

OK, with cfhttp and dump t

here is no error but how I can get the cfhttp in a query?

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 ,
Apr 18, 2011 Apr 18, 2011

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

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
Guest
Apr 18, 2011 Apr 18, 2011

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

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 ,
Apr 18, 2011 Apr 18, 2011

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

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
Guest
Apr 18, 2011 Apr 18, 2011
LATEST

Thanks Adam.

I do not like twitter either. It's a project at work.

Thanks for the time you put into this,

Mandana

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