Discussions
✅✅✅ Help to generating the first version 2 video
about 1 year ago by Ole Oldhoj
<?php
$apiKey = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx==';
$client = new \GuzzleHttp\Client();
$response = $client->request('GET', 'https://api.heygen.com/v1/video_status.get', [
'headers' => [
'accept' => 'application/json',
'x-api-key' => $apiKey,
],
]);
echo $response->getBody();
$heygen = SpaEntity::name('AI VIDEO Hengen.com')
->get();
foreach ($heygen as $spa) {
print("\n");
print($spa->URL);
print("\n");
}
$templateId = '9843b64e0acb90ccb26fd358ae86b638'; // my face and voice
$url = 'https://api.heygen.com/v2/template/' . $templateId;
$headers = [
'Accept: application/json',
'x-api-key: '.$apiKey
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
if ($response === false) {
echo 'Curl error: ' . curl_error($ch);
}
curl_close($ch);
print("\n Getting the overview \n");
echo $response;
print("\n");
$data = [
"test" => true,
"caption" => true,
"title" => "new video ",
"variables" => [
"company" => [
"name" => "company",
"type" => "text",
"properties" => [
"content" => "Ole Oldhøj cleaning service"
]
],
"FirstName" => [
"name" => "company",
"type" => "text",
"properties" => [
"content" => "Ole"
]
]
]
];
$ch = curl_init('https://api.heygen.com/v2/template/' . $templateId . '/generate');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'X-Api-Key: ' . $apiKey,
'Content-Type: application/json'
]);
$response = curl_exec($ch);
curl_close($ch);
print("\n Getting the VIDEO\n");
echo $response ;
$responseObj = json_decode($response);
// Access the video_id property
$videoId = $responseObj->data->video_id;
$VIDEOURL = "https://app.heygen.com/videos/" . $videoId;
print("\n video url \n");
print($VIDEOURL);
print("\n video url \n");