curl php to http redirecting to an https

4

I have a problem, I try to curl a url that contains a post to an https url, the problem is that I only capture the first url and jump to the second but it does not capture it.

url 1: http: //s7494.home. us/m/fun4.php
url 2: https: www.url.com

this is the code of my curl

link: http: //s7494.home. us/m/ m/in4d.php

<?php 
    $url = "http: //s7494.home. us/m/fun1.php"; //Let me say for example take paypal.com and try 
    $connection = curl_init(); 
    curl_setopt($connection, CURLOPT_TIMEOUT, 5); 
    curl_setopt($connection, CURLOPT_URL, $url); 
    curl_setopt($connection, CURLOPT_RETURNTRANSFER, 1); 
    curl_setopt($connection, CURLOPT_SSL_VERIFYPEER, 2); 
    curl_setopt($connection, CURLOPT_SSL_VERIFYHOST, 2); 
    curl_setopt($connection, CURLPROTO_HTTPS, 1);
    curl_setopt($connection, CURLOPT_REFERER, $url); 
    curl_setopt($connection, CURLOPT_MAXREDIRS, 10); 
    curl_setopt($connection, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)'); 
    curl_setopt($connection, CURLOPT_FOLLOWLOCATION, 1); 
    $result = curl_exec($connection); 
    curl_close($connection); 
    echo $result;
?>
    
asked by Isaias silva amaya 12.07.2016 в 10:24
source

1 answer

1

For curl to follow the redirection with the option CURLOP_FOLLOWLOCATION in theory you would have solved it, but I think that is not the problem, since there is no redirection. You can check the answer of the connection with:

echo curl_getinfo($connection, CURLINFO_HTTP_CODE);

The url link has this tag:

<body onLoad="document.getElementById('form').submit()">

When you do the echo, the onload event is triggered and the form submit, but in no case is it a redirect.

    
answered by 12.07.2016 в 11:46