Error when uploading image in album - Missing Mashape application key

27 views
Skip to first unread message

Alex

unread,
Mar 29, 2016, 12:36:19 PM3/29/16
to Imgur
For uploading image in albums on `imgur.com` we are useing it information and its code:

    if(isset($_FILES['upload']['tmp_name'])) {
            $imgbinary = fread(fopen($_FILES['upload']['tmp_name'], "r"), filesize($_FILES['upload']['tmp_name']));
            $image = 'data:image/png;base64,' . base64_encode($imgbinary);
    }
    
    $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, array( 'Authorization: Client-ID ' . $client_id ));
    curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'X-Mashape-Key: '. $xmash)); //. $xmash 
    curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type:  application/x-www-form-urlencoded' ));
    curl_setopt($ch, CURLOPT_POSTFIELDS, array( 'image' => $image ));
    curl_setopt($ch, CURLOPT_POSTFIELDS, array( 'album' => $album_id ));
    curl_setopt($ch, CURLOPT_POSTFIELDS, array( 'type' => 'base64' ));
    curl_setopt($ch, CURLOPT_POSTFIELDS, array( 'name' => 'test_name' ));
    curl_setopt($ch, CURLOPT_POSTFIELDS, array( 'title' => 'test title' ));
    curl_setopt($ch, CURLOPT_POSTFIELDS, array( 'description' => 'blablabla' ));
    
    
    $reply = curl_exec($ch);
    var_dump($reply);
    curl_close($ch);

But now we are get error in answer:

> string(134) "{"message":"Missing Mashape application key. Go to
> http:\/\/docs.mashape.com\/api-keys to learn how to get your API
> application key."}"

Why we get error and how upload image?

P.S.: we are copying real Mashape Application key as on page http://docs.mashape.com/api-keys

Alex

unread,
Mar 29, 2016, 5:09:05 PM3/29/16
to Imgur
SOLVED
Reply all
Reply to author
Forward
0 new messages