Https request to another domain with redirection using php

I have a link to automatically log into one domain - this domain is used for authorization:

https://example.com/api/login/{key}/{username}

After this link, the user is redirected to the control panel:

https://example.com

If something is wrong - the user is redirected to

https://example.com/login page.

In another domain example2.com, users have a billing panel, and a link is placed in it https://example.com/api/login/{key}/{username}.

So I need to do a check from example2.comto example.comas follows:

$url = https://example.com/api/login/{key}/{username};
if function-to-check-autologin($url) == "true" {
  //do something
}

My search result is curl, but I can not configure the query myself.

How could I do this? curl or other way?

0
source share
2 answers

, " " . "example.com", . , . , .

, , , .

, .

, SSL- , . , .

  1. , . . , . , , , :

    https://example.com?key=DgGyC28Sw3eQFvY9hz2dBkfmCa5zMgV6nN4Jj8VeD76chf7

, , . , .

, URL- , . SSL , .

0

, .

, CURLOPT_SSL_VERIFYPEER false, peer.

CURL . , CURLOPT_FOLLOWLOCATION, CURLOPT_MAXREDIRS CURLOPT_AUTOREFERER.

POST CURLOPT_POST true CURLOPT_POSTFIELDS POST , URL.

CURL , curl_getinfo. CURLINFO_REDIRECT_COUNT , CURLINFO_EFFECTIVE_URL - URL.

, :

$ch = curl_init();
curl_setopt_array($ch, array(
    CURLOPT_URL => $url,
    CURLOPT_NOBODY => false,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_SSL_VERIFYPEER => false,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_MAXREDIRS => 1,
    CURLOPT_AUTOREFERER => true,
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => $data_array,
));
$response = curl_exec($ch);
if (curl_getinfo($ch, CURLINFO_REDIRECT_COUNT) == 1 && curl_getinfo($ch, CURLINFO_EFFECTIVE_URL) == $sample_redirect_url)
    echo 'OK';
0

All Articles