Curl Cannot Follow Redirect

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
User avatar
Grandong
Forum Commoner
Posts: 65
Joined: Thu Jul 03, 2014 12:35 pm
Location: Indonesian
Contact:

Curl Cannot Follow Redirect

Post by Grandong »

Hi... Please Help me to understand this problem:

this my case:
1. i try to login site via php curl

first, i need to visit login page Here
ths my code:

Code: Select all

		$ch = curl_init($url);
		curl_setopt($ch, CURLOPT_COOKIESESSION, true);
		// curl_setopt($ch, CURLOPT_HEADER, true);
		curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
	    curl_setopt($ch, CURLOPT_NOSIGNAL, 1);
	    curl_setopt($ch, CURLOPT_TIMEOUT_MS, 30000);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($ch, CURLOPT_HTTPHEADER, array('User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:19.0) Gecko/20100101 Firefox/19.0', 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',));
		curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, true);
		$result = curl_exec($ch);
	    $curl_errno = curl_errno($ch);
	    $curl_error = curl_error($ch);
	    if ($curl_errno > 0) {
	    	print_r($curl_errno);
	    }
	    print_r($result);
but, process stop in Connecting...

Please Help Me...
Newbie The Passion for Learning
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Curl Cannot Follow Redirect

Post by Christopher »

You may need to use CURLOPT_CUSTOMREQUEST. Read the docs.
(#10850)
Post Reply