1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

Failed to make calls: Arkesel Error: A 'contents' key is required

Discussão em 'Outras Linguagens' iniciado por Mahfuz Abdallah, Outubro 30, 2024 às 17:42.

  1. Trying to make voice sms with arkesel but anytime I run the command I get this error "Failed to make calls: Arkesel Error: A 'contents' key is required"

    I tried adding this `->asMultipart()` because testing the endpoint with postman using the form-data with 'voice_file'(which I uploaded to the postman) and 'recipients[]'(which was a phone number), it works in the postman

    public function makeCall($recipients)
    {
    $filePath = storage_path('app/public/assets/harvard.wav');

    // Check if the file exists
    if (!file_exists($filePath)) {
    throw new Exception("Audio file not found at {$filePath}");
    }

    try {
    $response = Http::withHeaders([
    'api-key' => $this->apiKey
    ])
    ->attach('voice_file', fopen($filePath, 'r'), 'harvard.wav') // Attach the audio file
    ->post('https://sms.arkesel.com/api/v2/sms/voice/send', [
    'recipients' => $recipients,
    ]);

    // Check for successful response
    if ($response->successful()) {
    Log::info("Voice SMS sent successfully with Arkesel: ", ['recipients' => $recipients, 'response' => $response->json()]);
    return $response->json();
    } else {
    Log::error("Voice SMS failed: ", ['recipients' => $recipients, 'error' => $response->body()]);
    throw new Exception("Arkesel Error: " . $response->body());
    }

    } catch (Exception $e) {
    Log::error("Voice SMS failed with exception: ", ['recipients' => $recipients, 'error' => $e->getMessage()]);
    throw new Exception("Arkesel Error: " . $e->getMessage());
    }
    }```

    Continue reading...

Compartilhe esta Página