Jump to content

Php - Curl redirection problem


dahype

Recommended Posts

Hello buddies, i got some problems writing a php that has to login to a https page and then perform some actions.

 

When i run it from my hosting i get this error

 

Not Found

 

The requested URL /hosting.com/page.php was not found on this server.

 

I used LiveHTTP Headers add-on for mozilla to get the steps right and i saw that "page.php" is the page to which the user is redirected to after logging in. Obviously that page cannot be found on MY hosting because it's on the server where i do the log in.

 

How can i solve that?

 

The code i am using for that is the following:

<?php

$face_cookie = "cookiefb.txt";

$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, 'https://loggingpage.com/index.php');
	curl_setopt($ch, CURLOPT_POSTFIELDS,'field1=xxx&field2=XXX&field3=XXX');
	curl_setopt($ch, CURLOPT_POST, 1);
	curl_setopt($ch, CURLOPT_HEADER, 0);
	curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
	curl_setopt($ch, CURLOPT_UNRESTRICTED_AUTH, 1);


	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);


	curl_setopt($ch, CURLOPT_COOKIEJAR, $face_cookie);
	curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3");
	echo curl_exec($ch);


?>

 

any ideas? thanks

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.