jeudi 22 mars 2018

Not able to send the .mp3 file in curl call

I am trying to send the .mp3 and .wav file by using curl call to the third party URL. But my .mp3 file is delivering on Thirty party. He is not receiving file, only path receiving "var/www/html/projectname/public/callRecord/sampleMP3.mp3"

Any help much appreciated.

    $token = 'abcd';
    $url = 'sample url';
    $filePath = public_path('callRecord/sampleMP3.mp3');

    $headers = [
        'Authorization: JWT '.$token,
        'Accept: application/json',
        'Content-Type: application/json',
    ];

    $payload = [
        'account' => '1234567',
        'name' => '22 march mp3 checking Tes',
        'schedule' => 1234,
        'audio' => '1234567'.$filePath,
        'max_ports' => 100,
        'callerids' => 12345
    ];

    $ch = curl_init();

    curl_setopt_array($ch, [
        CURLOPT_URL => $url,
        CURLOPT_HTTPHEADER => $headers,
        CURLOPT_CUSTOMREQUEST => 'POST',
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_POSTFIELDS => json_encode($payload),
    ]);

    $result = curl_exec($ch);
    $data = json_decode($result);
    print_r($data); die;



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire