Question

    $image = file_get_contents($_FILES['upload']['tmp_name']);
    $id = 'myid';
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 'https://api.imgur.com/3/image.json');
    curl_setopt($ch, CURLOPT_POST, TRUE);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Authorization: Client-ID ' . $id));
    curl_setopt($ch, CURLOPT_POSTFIELDS, array( 'image' => base64_encode($image) ));
    $response = curl_exec($ch);
    curl_close($ch);
    $response = json_decode($response);

this is the block of quote that i have to make anonymous image uploads to imgur. it works on xampp on my mac os machine, but it is not working on xampp on my windows. i also know the following about curl on windows xampp:

-it is enabled
-it works when i try to grab the content of an url
-it doesnt work when i try to make DELETE request to remove an anonymous image(the same code works on the mac os xampp)

i figured there are some differences between the cURL settings on the two computers. i would appreciate it if you can show me the ways! thanks in advance.

Was it helpful?

Solution

That's an SSL issue. Please try the following line before the curl_exec call

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

(And you might add var_dump($response); to see the server response.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top