General subject and ideas
husterdusk
shell scraper
Posts: 16 Joined: Fri Aug 04, 2023 7:16 am
Post
by husterdusk » Sun Jul 28, 2024 5:46 pm
Doodstream is a platform for storing videos and sharing them on social networks and personal websites. In addition, videos can be monetized. Many users have difficulty setting up the API, but it is quite simple to understand. Here is a small project to display your Doodstream videos remotely on your pages.
Important: never share your API data.
husterdusk
shell scraper
Posts: 16 Joined: Fri Aug 04, 2023 7:16 am
Post
by husterdusk » Sun Jul 28, 2024 6:37 pm
(1)
Installing your API
Code: Select all
$apiKey = '*******'; // Your API
$apiBaseUrl = 'https://doodapi.com/api';
husterdusk
shell scraper
Posts: 16 Joined: Fri Aug 04, 2023 7:16 am
Post
by husterdusk » Sun Jul 28, 2024 6:39 pm
(2) Making request
Code: Select all
function makeApiRequest($endpoint, $apiKey) {
$url = $endpoint . '?key=' . $apiKey;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
return json_decode($output, true);
}
husterdusk
shell scraper
Posts: 16 Joined: Fri Aug 04, 2023 7:16 am
Post
by husterdusk » Sun Jul 28, 2024 6:43 pm
(3) function with the "endpoint" of videos to call the list
Code: Select all
$videosEndpoint = $apiBaseUrl . '/file/list';
$response = makeApiRequest($videosEndpoint, $apiKey);
husterdusk
shell scraper
Posts: 16 Joined: Fri Aug 04, 2023 7:16 am
Post
by husterdusk » Sun Jul 28, 2024 6:48 pm
(4) If the response is successful (status == 200), it will go through the API and bring the thumbnail and the link of the videos. It can also be changed to go to a parameter of its own page.
Code: Select all
echo '<div class="container">';
if ($response && $response['status'] == 200) {
$videos = $response['result']['files'];
foreach ($videos as $video) {
echo '<div class="video-item">';
if (isset($video['single_img']) && !empty($video['single_img'])) {
echo '<div class="video-thumbnail"><img src="' . $video['single_img'] . '" alt="' . $video['title'] . '"></div>';
} else {
echo '<div class="video-thumbnail"><img src="default_thumbnail.jpg" alt="No Thumbnail"></div>';
}
echo '<div class="video-info">';
echo '<h3><a href="' . $video['download_url'] . '">' . $video['title'] . '</a></h3>';
echo '</div>';
echo '</div>';
}
} else {
echo 'Error list: ' . $response['msg'];
}
echo '</div>';
husterdusk
shell scraper
Posts: 16 Joined: Fri Aug 04, 2023 7:16 am
Post
by husterdusk » Sun Jul 28, 2024 7:02 pm
The result of code above with the implementation of just a simple CSS. We can also add a request for research by tags and video nicknames and make an implementation in the search bar