Commit ab940e0c authored by Okthane's avatar Okthane

Le détourage ne fonctionne qu'avec une image en ligne

parent 3afe14f4
-----BEGIN CERTIFICATE-----
MIIDdTCCAl2gAwIBAgILBAAAAAABFUtaw5QwDQYJKoZIhvcNAQEFBQAwVzELMAkG
A1UEBhMCQkUxGTAXBgNVBAoTEEdsb2JhbFNpZ24gbnYtc2ExEDAOBgNVBAsTB1Jv
b3QgQ0ExGzAZBgNVBAMTEkdsb2JhbFNpZ24gUm9vdCBDQTAeFw05ODA5MDExMjAw
MDBaFw0yODAxMjgxMjAwMDBaMFcxCzAJBgNVBAYTAkJFMRkwFwYDVQQKExBHbG9i
YWxTaWduIG52LXNhMRAwDgYDVQQLEwdSb290IENBMRswGQYDVQQDExJHbG9iYWxT
aWduIFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDaDuaZ
jc6j40+Kfvvxi4Mla+pIH/EqsLmVEQS98GPR4mdmzxzdzxtIK+6NiY6arymAZavp
xy0Sy6scTHAHoT0KMM0VjU/43dSMUBUc71DuxC73/OlS8pF94G3VNTCOXkNz8kHp
1Wrjsok6Vjk4bwY8iGlbKk3Fp1S4bInMm/k8yuX9ifUSPJJ4ltbcdG6TRGHRjcdG
snUOhugZitVtbNV4FpWi6cgKOOvyJBNPc1STE4U6G7weNLWLBYy5d4ux2x8gkasJ
U26Qzns3dLlwR5EiUWMWea6xrkEmCMgZK9FGqkjWZCrXgzT/LCrBbBlDSgeF59N8
9iFo7+ryUp9/k5DPAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8E
BTADAQH/MB0GA1UdDgQWBBRge2YaRQ2XyolQL30EzTSo//z9SzANBgkqhkiG9w0B
AQUFAAOCAQEA1nPnfE920I2/7LqivjTFKDK1fPxsnCwrvQmeU79rXqoRSLblCKOz
yj1hTdNGCbM+w6DjY1Ub8rrvrTnhQ7k4o+YviiY776BQVvnGCv04zcQLcFGUl5gE
38NflNUVyRRBnMRddWQVDf9VMOyGj/8N7yy5Y0b2qvzfvGn9LhJIZJrglfCm7ymP
AbEVtQwdpf5pLGkkeB6zpxxxYu7KyJesF12KwvhHhm4qxFYxldBniYUr+WymXUad
DKqC5JlR3XC321Y9YeRq4VzW9v493kHMB65jUr9TU/Qr6cf9tveCX4XSQRjbgbME
HMUfpIBvFSDJ3gyICh3WZlXi/EjJKSZp4A==
-----END CERTIFICATE-----
{"errors":[{"title":"No image given","code":"missing_source","detail":"Please provide the source image in the image_url, image_file or image_file_b64 parameter."}]}
\ No newline at end of file
<?php <?php
// phpinfo();die;
// Generated by curl-to-PHP: http://incarnate.github.io/curl-to-php/ // Generated by curl-to-PHP: http://incarnate.github.io/curl-to-php/
// if($_SERVER["REQUEST_METHOD"] == "POST") // if($_SERVER["REQUEST_METHOD"] == "POST")
// { // {
...@@ -11,34 +12,45 @@ ...@@ -11,34 +12,45 @@
// $ext = pathinfo($filename, PATHINFO_EXTENSION); // $ext = pathinfo($filename, PATHINFO_EXTENSION);
// if(array_key_exists($ext, $allowed)) // if(array_key_exists($ext, $allowed))
// { // {
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $curl = curl_init('https://api.remove.bg/v1.0/removebg');
// curl_setopt($ch, CURLOPT_CAINFO,__DIR__ . DIRECTORY_SEPARATOR . 'certif.cer');
// curl_setopt($ch, CURLOPT_CAPATH,__DIR__ . DIRECTORY_SEPARATOR); // curl_setopt($curl, CURLOPT_URL, 'https://api.remove.bg/v1.0/removebg');
curl_setopt($ch, CURLOPT_URL, 'https://api.remove.bg/v1.0/removebg'); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_POST, 1); // curl_setopt($curl, CURLOPT_CAINFO,__DIR__ . DIRECTORY_SEPARATOR . 'certif.cer');
// curl_setopt($curl, CURLOPT_CAPATH,__DIR__ . DIRECTORY_SEPARATOR);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
$post = array( $post = array(
// 'image_file' => '@' .realpath('/img'.$_FILES["photo"]["name"]), // 'image_file' => '@' .realpath('/img'.$_FILES["photo"]["name"]),
'image_file' =>'@' .realpath('/img/'.'pierremarque.jpg') , // 'image_url' => 'https://img.buzzfeed.com/buzzfeed-static/static/2019-04/18/5/asset/buzzfeed-prod-web-05/sub-buzz-18749-1555581339-1.jpg',
'image_file' =>'img'.'/pierremarque.jpg' ,
'size' => 'auto', 'size' => 'auto',
'format'=>'JPG'
); );
curl_setopt($ch, CURLOPT_POSTFIELDS, $post); // $post = http_build_query($post);
echo $post['image_file'];
echo'<br></br>';
curl_setopt($curl, CURLOPT_POSTFIELDS, $post);
$headers = array(); $headers = array();
// $headers[] = 'Content-type: plain/text';
$headers[] = 'X-Api-Key:qYXf5PimffLjeH1i5B1rySQw'; $headers[] = 'X-Api-Key:qYXf5PimffLjeH1i5B1rySQw';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); // echo $headers[0]." ".$headers[1];echo'<br></br>';
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch); $result = curl_exec($curl);
if (curl_errno($ch)) { echo $result;
echo 'Error:' . curl_error($ch); if (curl_errno($curl)) {
echo 'Error:' . curl_error($curl);
} }
curl_close($ch); curl_close($curl);
// $fp = fopen($_FILES["photo"]["name"]."no-bg.png", "wb"); // $fp = fopen($_FILES["photo"]["name"]."no-bg.png", "wb");
// $fp = fopen("no-bg.png", "wb"); $fp = fopen("no-bg.png", "wb");
// fwrite($fp, $result); fwrite($fp, $result);
// fclose($fp); fclose($fp);
// } // }
// } // }
// } // }
......
<?php
// $curl = curl_init('http://api.openweathermap.org/data/2.5/weather?lat=35&lon=139&appid=efa3ab7641e003e1076a68002b0880a4');
// curl_setopt($curl, CURLOPT_CAINFO,__DIR__ . DIRECTORY_SEPARATOR . 'certif.cer');
// curl_setopt($curl, CURLOPT_CAPATH,__DIR__ . DIRECTORY_SEPARATOR);
// $data = curl_exec($curl);
// if ($data === false || curl_errno($curl))
// {
// var_dump(curl_error($curl));
// }
// curl_close($curl);
?>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment