How do I curl an https that gives me a 302 error

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
lecapati
New php-forum User
New php-forum User
Posts: 5
Joined: Thu Jun 22, 2017 8:27 am

Sat Sep 30, 2017 7:35 am

I have the following function, and it works ok if the site is http,
but as soon as I add s i get this error.

I am on localhost BTW. is this something I can do?

Cheers

Code: Select all

function openDomainPage(){
        
        
    $curl = curl_init();
    curl_setopt ($curl, CURLOPT_URL, "https://www.google.com");
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,  2);

    $result = curl_exec ($curl);
    curl_close ($curl);
    print $result;
        
    }

lecapati
New php-forum User
New php-forum User
Posts: 5
Joined: Thu Jun 22, 2017 8:27 am

Sat Sep 30, 2017 8:56 am

I got it working with

Code: Select all

curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

Post Reply