Reputation: 971
I need to navigate in a website for send data in a web service.
First, i need to login in : http.://192.168.1.1/event/users/sign_in Then, i will redirect a another page that is: http.://192.168.1.1/event Finally, i need to go another page that is: http.://192.168.1.1/event/management/attendee In this page, i need to send some data in array by method POST.
I post my code but don't work.
/* For login */
$userpwd = "root:root";
$curl_rsc = curl_init();
curl_setopt($curl_rsc, CURLOPT_URL, $url_login);
curl_setopt($curl_rsc, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($curl_rsc, CURLOPT_HTTPAUTH, HTTP_AUTH_BASIC);
curl_setopt($curl_rsc, CURLOPT_USERPWD, $userpwd); //Here i have some doubts. Because if i change this variable always have a http_code = 200.
// or i need to send data in a array for login?
curl_setopt($curl_rsc, CURLOPT_RETURNTRANSFER, TRUE);
curl_exec($curl_rsc); // Get a http_code = 200
/* For go to the redirect page */
curl_setopt($curl_rsc, CURLOPT_URL, $url_next);
curl_setopt($curl_rsc, CURLOPT_FAILONERROR, TRUE);
curl_setopt($curl_rsc, CURLOPT_RETURNTRANSFER, TRUE);
curl_exec($curl_rsc); //Get a http_code = 200
/* For go to the target url when i want to send data */
curl_setopt($curl_rsc, CURLOPT_URL, $url_target);
curl_setopt($curl_rsc, CURLOPT_POST, TRUE);
curl_setopt($curl_rsc, CURLOPT_POSTFIELDS, $attendee); //Send the data in a array
curl_setopt($curl_rsc, CURLOPT_FAILONERROR, TRUE);
curl_setopt($curl_rsc, CURLOPT_TIMEOUT, 50);
curl_exec($curl_rsc); // Get a http_code = 500 Internal Server Error.
Can anyone tell me what is my error? Thanks :D
Upvotes: 0
Views: 2316
Reputation: 3358
Here i have some doubts. Because if i change this variable always have a http_code = 200.
Are you using HTTP authentication? If not this is the wrong thing to do. Other than that, your script on the last page is failing so you need to check your server error logs to find out what's going on; there doesn't appear to be anything wrong with your code.
Upvotes: 1