<?php
// Replace YOUR_API_KEY with your OpenAI API key
$api_key = "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";
// The keyword that will be used to generate the video's title, description, and keywords
$keyword = "example keyword";
// The prompt that will be passed to the OpenAI API
$prompt = "Generate a title, description, and keywords for a YouTube video about '$keyword':";
// The URL of the OpenAI API endpoint
$api_url = "https://api.openai.com/v1/engines/davinci/completions";
// Create the data array that will be passed to the API
$data = array(
"prompt" => $prompt,
"temperature" => 0.5,
"max_tokens" => 50,
);
// Encode the data array as JSON
$data_json = json_encode($data);
// Create the cURL request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $api_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_json);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Content-Type: application/json",
"Authorization: Bearer " . $api_key
));
// Execute the cURL request
$result = curl_exec($ch);
// Decode the JSON response
$response = json_decode($result, true);
// Extract the generated title, description, and keywords from the response
$generated_title = $response["choices"][0]["text"];
$generated_description = $response["choices"][1]["text"];
$generated_keywords = $response["choices"][2]["text"];
// Print the generated title, description, and keywords
echo "Title: $generated_title\n";
echo "Description: $generated_description\n";
echo "Keywords: $generated_keywords\n";
// Close the cURL connection
curl_close($ch);
?>