curl - Need Help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jaiswarvipin
Forum Commoner
Posts: 32
Joined: Sat Sep 12, 2009 3:43 pm
Location: India

curl - Need Help

Post by jaiswarvipin »

Hi All,
Last edited by jaiswarvipin on Tue Sep 22, 2009 10:58 am, edited 2 times in total.
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: curl - Need Help

Post by Darhazer »

Add CURLOPT_FOLLOWLOCATION option to the curl
jaiswarvipin
Forum Commoner
Posts: 32
Joined: Sat Sep 12, 2009 3:43 pm
Location: India

Re: curl - Need Help

Post by jaiswarvipin »

Thanks , it works.
Last edited by jaiswarvipin on Tue Sep 22, 2009 10:58 am, edited 1 time in total.
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: curl - Need Help

Post by Darhazer »

For some reason the live server gives 301 - Moved permanently on that URL. Normally browser will just redirect you to the new location, but curl does not, unless you specify FOLLOWLOCATION
jaiswarvipin
Forum Commoner
Posts: 32
Joined: Sat Sep 12, 2009 3:43 pm
Location: India

Re: curl - Need Help

Post by jaiswarvipin »

Hi it work,
Last edited by jaiswarvipin on Tue Sep 22, 2009 10:58 am, edited 1 time in total.
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: curl - Need Help

Post by Darhazer »

Add:
echo $xml / var_dump($xml)
before initializing SimpleXML
in order to see what the server is receiving

P.S. It seems that the server does not receive anything.
jaiswarvipin
Forum Commoner
Posts: 32
Joined: Sat Sep 12, 2009 3:43 pm
Location: India

Re: curl - Need Help

Post by jaiswarvipin »

very true,
Last edited by jaiswarvipin on Tue Sep 22, 2009 10:59 am, edited 1 time in total.
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: curl - Need Help

Post by Darhazer »

The problem is that it does not post the data when the servers redirects to another URL
Maybe this is according to a RFC, I don't know.
Maybe there is workaround. Dig for it.
Or instead of CURLOPT_FOLLOWREDIRECT, parse the header of the response, and if it is 3xx, post the data to the new location. Manually.
jaiswarvipin
Forum Commoner
Posts: 32
Joined: Sat Sep 12, 2009 3:43 pm
Location: India

Re: curl - Need Help

Post by jaiswarvipin »

I have enable the Header true and found this response form server.
Last edited by jaiswarvipin on Tue Sep 22, 2009 10:59 am, edited 1 time in total.
jaiswarvipin
Forum Commoner
Posts: 32
Joined: Sat Sep 12, 2009 3:43 pm
Location: India

Re: curl - Need Help

Post by jaiswarvipin »

Thanks a lot. :D
AS you suggested i have dig into that and you line instruction is 100% right?
Server response is going some where else, after monitoring i have found that server send's the response but it get redirected to other server whcih is not exists at all.

Thanks a lot dear.
:D
Post Reply