-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpage.php
59 lines (55 loc) · 1.37 KB
/
page.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<!DOCTYPE html>
<html>
<head>
<title>Fetch Comments</title>
<style type="text/css">
body{
padding: 40px 100px;
font-family: "verdana";
font-size: 14px;
}
table{
width: 100%;
text-align: center;
margin-top: 15px;
}
table thead tr{
background:#cccccc91;
}
form{
text-align: center;
}
</style>
</head>
<body>
<form action="" method="POST">
<input type="number" name="id">
<button type="submit" name="submit">RUN</button>
</form>
</body>
</html>
<?php
if(isset($_POST['submit'])){
$ch = curl_init();
$post = $_POST['id'];
curl_setopt($ch, CURLOPT_URL, "https://graph.facebook.com/v3.1/".$post."/comments?limit=10000&access_token=PASTE_YOUR_ACCESS_TOKEN_HERE");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$results = curl_exec($ch);
$results = json_decode($results);
if(isset($results->data)){
$results = $results->data;
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close ($ch);
echo "<table>";
echo "<thead><tr><th>Date time</th><th>Name</th><th>Comment</th><th>..</th></tr></thead><tbody>";
foreach($results as $result){
echo '<tr><td>'.$result->created_time.'</td><td>'.$result->from->name.'</td><td>'.$result->message.'</td><td><a href="https://www.facebook.com/'.$result->id.'">Visit Comment</a></td></tr>';
}
echo "<tbody></table>";
}else{
echo "Something went wrong try again !";
}
}
?>