Skip to content

Commit 93eb4ec

Browse files
authored
Create fb.php
0 parents  commit 93eb4ec

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

fb.php

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
3+
/// Posted on @TheSmartDev || @ISmartDevs
4+
/// Developer @ISmartDevs
5+
header("Content-Type: application/json; charset=UTF-8");
6+
7+
if (!isset($_GET['url']) || empty($_GET['url'])) {
8+
echo json_encode([
9+
"error" => "Hey Bro Kindly Give URL",
10+
"dev" => "@ISmartDevs",
11+
"channel" => "@TheSmartDev"
12+
], JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
13+
exit;
14+
}
15+
16+
$facebook_video_url = $_GET['url'];
17+
$encoded_url = urlencode($facebook_video_url);
18+
$api_url = "https://tooly.chative.io/facebook/video?url=" . $encoded_url;
19+
20+
$ch = curl_init();
21+
curl_setopt($ch, CURLOPT_URL, $api_url);
22+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
23+
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
24+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
25+
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
26+
$response = curl_exec($ch);
27+
if (curl_errno($ch)) {
28+
echo json_encode([
29+
"error" => "cURL error: " . curl_error($ch),
30+
"dev" => "@ISmartDevs",
31+
"channel" => "@TheSmartDev"
32+
], JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
33+
curl_close($ch);
34+
exit;
35+
}
36+
curl_close($ch);
37+
$data = json_decode($response, true);
38+
39+
if ($data && isset($data["success"]) && $data["success"] === true) {
40+
$title = $data["title"] ?? "No Title";
41+
$sd_url = $data["videos"]["sd"]["url"];
42+
$hd_url = $data["videos"]["hd"]["url"];
43+
$result = [
44+
"success" => true,
45+
"title" => $title,
46+
"sd_url" => $sd_url,
47+
"hd_url" => $hd_url,
48+
"dev" => "@ISmartDevs",
49+
"channel" => "@TheSmartDev"
50+
];
51+
} else {
52+
$result = [
53+
"success" => false,
54+
"error" => $data["message"] ?? "Unknown error",
55+
"dev" => "@ISmartDevs",
56+
"channel" => "@TheSmartDev"
57+
];
58+
}
59+
60+
echo json_encode($result, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
61+
62+
?>

0 commit comments

Comments
 (0)