Created
June 24, 2020 18:46
-
-
Save mattiaa95/9dcc0885c426d6b9b82b795756c85945 to your computer and use it in GitHub Desktop.
PHP Post replication to other domain with disable SSL Verification
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//API URL | |
$url = ''; | |
$ch = curl_init($url); | |
$jsonDataEncoded = file_get_contents('php://input'); | |
curl_setopt($ch, CURLOPT_POST, 1); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonDataEncoded); | |
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); | |
curl_exec($ch); | |
if (!curl_errno($ch)) { | |
switch ($http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE)) { | |
case 200: | |
echo($html); | |
break; | |
default: | |
http_response_code($http_code); | |
} | |
} | |
curl_close($ch); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment