homepage Welcome to WebmasterWorld Guest from 54.166.113.249
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Curl in Crontab - Getting "You are not authorized to view this page."
Can't find a solution anywhere
wfernley

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 3801351 posted 1:55 am on Dec 6, 2008 (gmt 0)

Hey everyone,

I have a php script using curl to login to a website and grab data from the page.

It works fine when run in a web browser however as soon as I set it up to run as a cron job, it doesn't work.

When running it via command line in my linux server, I get an error "You are not authorized to view this page."

I get this using curl and lynx

Has anyone experienced this before? I tried searching and can't find anything. I have tried running the script via root as well.

I'm assuming it has to be an issue with the php script using curl.

Can anyone help?

Thanks in advance for your help!

Wes

 

Anyango

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 3801351 posted 6:56 am on Dec 6, 2008 (gmt 0)

What User-Agent are you setting when calling the script from cron job ? they might be blocking based upon that.

wfernley

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 3801351 posted 5:07 pm on Dec 6, 2008 (gmt 0)

I tried with both curl and lynx.

For example typing in:

curl [mysite.com...]

Returns "You are not authorized to view this page."

Let me know if I'm missing anything or if I should be specifying another user-agent (I'm assuming that curl and lynx are user agents right?)

The browsers it works fine with are FireFox and IE.

Thanks again for your help!

Wes

wfernley

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 3801351 posted 5:30 pm on Dec 6, 2008 (gmt 0)

Me again,

I did some researching and found that you can specify a useragent in curl. After doing this, it works fine :)

Anyango

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 3801351 posted 6:49 pm on Dec 6, 2008 (gmt 0)

Cool, Congrats ;)

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved