save to codehub

This commit is contained in:
vedant-chavan
2024-08-09 17:11:41 +05:30
commit 20f55281ef
412 changed files with 74718 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
<?php
function shortenVideoUrl($longUrl) {
$accessToken = 'YOUR_ACCESS_TOKEN'; // replace with your Bitly access token
$url = 'https://api-ssl.bitly.com/v4/shorten';
$data = array(
'long_url' => $longUrl,
);
$headers = array(
'Authorization: Bearer ' . $accessToken,
'Content-Type: application/json',
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
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, $headers);
$result = curl_exec($ch);
curl_close($ch);
$response = json_decode($result, true);
return $response['link'];
}
?>