Imgur Error 400 "Invalid URL ()"

253 views
Skip to first unread message

Alex

unread,
Mar 30, 2016, 10:46:59 AM3/30/16
to Imgur
For upload image working next code:

    $client_id = "123123asdasd3123"; //example(not real) client_id
    $Mashape_Key
= "fsdfasdfdfarewr2342432231231"; //example(not real) X-Mashape-Key
    $headers
= array('Authorization: Client-ID ' . $client_id, 'X-Mashape-Key: ' . $Mashape_Key);
   
    $image
= $_POST['url']; // i send image url, example http://i.imgur.com/w9eZVxW.png
    $post_arr
= array(
       
'image' => $image,
       
'type' => 'url',
       
'name' => 'test_name',
       
'title' => 'test title',
       
'description' => 'blablabla'
   
);


    $ch
= curl_init();
    curl_setopt
($ch, CURLOPT_URL, 'https://imgur-apiv3.p.mashape.com/3/image');
    curl_setopt
($ch, CURLOPT_POST, TRUE);
    curl_setopt
($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt
($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt
($ch, CURLOPT_POSTFIELDS, $post_arr);


    $reply
= curl_exec($ch);
    var_dump
($reply);
    curl_close
($ch);


    $reply
= json_decode($reply);
    $newimgurl
= $reply->data->link;


    echo $newimgurl
;


But i get error:

string(105) "{"data":{"error":"Invalid URL ()","request":"\/3\/image\/","method":"POST"},"success":false,"status":400}"


Tell me please what url need ?
Reply all
Reply to author
Forward
0 new messages