Discussions

Ask a Question
Back to All

Talks API Integration

Hey, i'm trying to integrate D-ID Talks API in my system. I'm coding in Laravel PHP. This is my sample code so far, and my source_url looks something like this
http://my-site/storage/user/avatar-image/user_id/picture.jpg

My code so far

    $body = [
        'source_url' => asset($userAvatar->image),
        'script' => [
            'type' => 'text',
            'subtitles' => false,
            'provider' => [
                'type' => 'elevenlabs',
                'voice_id' => $voice_id 
            ],
            'input' => "Laravel is a popular PHP framework used for building web applications. It provides a robust set of tools and features for quickly developing and deploying web projects. Some key features of Laravel include its elegant syntax, built-in authentication system, powerful ORM (Object-Relational Mapping) for working with databases, routing capabilities, middleware support, and more. Laravel is known for its simplicity, performance, and scalability, making it a preferred choice for many developers when working on web development projects."
        ],
        'config' => [
            'fluent' => false,
            'pad_audio' => 0.0
        ]
    ]; 
    $response = $client->request('POST', 'https://api.d-id.com/talks', [
        'body' => json_encode($body),
        'headers' => [
            'accept' => 'application/json',
            'content-type' => 'application/json',
            'authorization' => 'Basic '.config('services.d-id.api_key'),
        ],
    ]);
    dd(json_decode($response->getBody()->getContent(), true), $response);

But it is throwing me 400 bad request saying
Client error: POST https://api.d-id.com/talks resulted in a 400 Bad Request response:\n{"kind":"ValidationError","description":"validation failed","details":{"body.source_url":{"message":"must be a valid ima (truncated...)\n",
Why is it so?