• Purchasing a license grants permission to use the software and to get Tech Support. A license purchase doesn't grant customization support.

How to send post to API url

makaja2

Network license
License owner
Joined
Jul 29, 2014
Messages
96
Points
68
Hi, i try send upload with API, but when i use curl, it show me error:

{"status_code":400,"error":{"message":"Invalid base64 string.","code":120,"context":"Exception"},"status_txt":"Bad Request"}

I'm post with source = $_FILE[file];

And when i try with source = base64_encode($_FILE[file]); it show me Invalid file extension

Can you help me fix that.

Thanks
 

makaja2

Network license
License owner
Joined
Jul 29, 2014
Messages
96
Points
68
Code:
$url = 'https://likz.me/api/1/upload/?key=xxx';
$source = $_FILES["file"];
        $data = array('source' => ($source), 'format' => 'json');
        foreach($data as $key=>$value) { @$fields_string .= $key.'='.$value.'&'; }
        rtrim($fields_string,'&');

        //open connection
        $ch = curl_init();

        //set the url, number of POST vars, POST data
        curl_setopt($ch,CURLOPT_URL,$url);
        curl_setopt($ch,CURLOPT_POST,count($data));
        curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

        //execute post
        $result = curl_exec($ch);
        var_dump($result);
        exit;
Please help me, thanks
This script upload work fine with remote url