Streamtape API
- husterdusk
- shell scraper
- Posts: 16
- Joined: Fri Aug 04, 2023 7:16 am
Streamtape API
A simple project to manipulate the Streamtape platform API. I see that many people have difficulty using its API, even with the information. It is a bit complex to assemble and use, so I come in this topic to share how to manipulate the Streamtape /API.
Important: never share your API data.
Last edited by husterdusk on Sun Jul 28, 2024 12:16 am, edited 1 time in total.
- husterdusk
- shell scraper
- Posts: 16
- Joined: Fri Aug 04, 2023 7:16 am
Re: Streamtape API
(1) PHP
Replace "username", "password", and "folderId" with your actual Streamtape API credentials
Replace "username", "password", and "folderId" with your actual Streamtape API credentials
Code: Select all
$username = '******'; // username
$password = '*******'; // password
$folderId = '******'; // ID of the folder
- husterdusk
- shell scraper
- Posts: 16
- Joined: Fri Aug 04, 2023 7:16 am
Re: Streamtape API
(2)
Configure URL and parameters
Configure URL and parameters
Code: Select all
$listUrl = 'https://api.streamtape.com/file/listfolder';
$listParams = [
'login' => $username,
'key' => $password,
'folder' => $folderId
];
- husterdusk
- shell scraper
- Posts: 16
- Joined: Fri Aug 04, 2023 7:16 am
Re: Streamtape API
(3)
send a POST request
send a POST request
Code: Select all
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $listUrl);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $listParams);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($curl);
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
- husterdusk
- shell scraper
- Posts: 16
- Joined: Fri Aug 04, 2023 7:16 am
Re: Streamtape API
(4)
And to finish process the response data using some conditions
And to finish process the response data using some conditions
Code: Select all
if ($httpCode === 200) {
$responseData = json_decode($response, true);
if (isset($responseData['result']) && is_array($responseData['result'])) {
$files = $responseData['result']['files'];
if (!empty($files)) {
echo '<h2>Videos in Folder</h2>';
echo '<ul>';
foreach ($files as $file) {
$fileId = $file['linkid'];
$fileName = $file['name'];
$fileUrl = $file['link'];
$thumbnailUrl = 'https://api.streamtape.com/file/getsplash?login=' . $username . '&key=' . $password . '&file=' . $fileId;
$curlThumb = curl_init();
curl_setopt($curlThumb, CURLOPT_URL, $thumbnailUrl);
curl_setopt($curlThumb, CURLOPT_RETURNTRANSFER, true);
$thumbnailResponse = curl_exec($curlThumb);
curl_close($curlThumb);
$thumbnailData = json_decode($thumbnailResponse, true);
$thumbnailUrl = $thumbnailData['result']; // Thumbnail URL
echo '<li><a href="' . $fileUrl . '">' . $fileName . '</a><br>';
echo '<img src="' . $thumbnailUrl . '" alt="Thumbnail"></li>';
}
echo '</ul>';
} else {
echo ' folder is empty.';
}
} else {
echo 'Error retrieving the file list from the folder.';
}
} else {
echo 'Error connecting. HTTP: ' . $httpCode;
}
?>
- husterdusk
- shell scraper
- Posts: 16
- Joined: Fri Aug 04, 2023 7:16 am
Re: Streamtape API
(5)
The style choice is up to you.
Result
The style choice is up to you.
Result