Skip to content

Commit 82cbed3

Browse files
committed
instagram graph api webhooks
1 parent 670e0d2 commit 82cbed3

3 files changed

Lines changed: 98 additions & 0 deletions

File tree

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
stdClass Object
2+
(
3+
[object] => instagram
4+
[entry] => Array
5+
(
6+
[0] => stdClass Object
7+
(
8+
[id] => 0
9+
[time] => 1586915724
10+
[changes] => Array
11+
(
12+
[0] => stdClass Object
13+
(
14+
[field] => mentions
15+
[value] => stdClass Object
16+
(
17+
[media_id] => 17887498072083520
18+
[comment_id] => 17887498072083520
19+
)
20+
21+
)
22+
23+
)
24+
25+
)
26+
27+
)
28+
29+
)
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php
2+
//include '../defines.php';
3+
4+
// VERIFICATION STEPS
5+
//file_put_contents( 'verify.log', print_r( $_GET, true ), FILE_APPEND );
6+
//echo $_GET['hub_challenge'];
7+
//die();
8+
9+
// TESTING OF THE WEBHOOKS
10+
// $json = file_get_contents( 'php://input' );
11+
// $data = json_decode( $json );
12+
// file_put_contents( 'data.log', print_r( $data, true ), FILE_APPEND );
13+
// //die();
14+
15+
// $commentId = '17893015459452492';
16+
// $mediaId = '17908649842399636';
17+
18+
// $params = array(
19+
// 'endpoint_url' => 'https://graph.facebook.com/' . $instagramAccountId . '/mentions',
20+
// 'type' => 'POST',
21+
// 'url_params' => array(
22+
// 'comment_id' => $commentId,
23+
// 'media_id' => $mediaId,
24+
// 'message' => 'This is an auto reply from a webhook!',
25+
// 'access_token' => $accessToken,
26+
// )
27+
// );
28+
29+
// $responseInfo = makeApiCall( $params );
30+
31+
// echo '<pre>';
32+
// print_r($responseInfo);
33+
34+
function makeApiCall( $params ) {
35+
$ch = curl_init();
36+
37+
curl_setopt( $ch, CURLOPT_POSTFIELDS, http_build_query( $params['url_params'] ) );
38+
curl_setopt( $ch, CURLOPT_POST, 1 );
39+
40+
curl_setopt( $ch, CURLOPT_URL, $params['endpoint_url'] );
41+
42+
// set other curl options
43+
curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false );
44+
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, true );
45+
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
46+
47+
$response = curl_exec( $ch );
48+
49+
curl_close( $ch );
50+
51+
$responseArray = json_decode( $response, true );
52+
53+
return $responseArray;
54+
}
55+
?>
56+
<html>
57+
<head>
58+
<title>Instagram Graph API Webhooks</title>
59+
</head>
60+
<body>
61+
<h1>Instagram Graph API Webhooks</h1>
62+
</body>
63+
</html>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Array
2+
(
3+
[hub_mode] => subscribe
4+
[hub_challenge] => 1954612326
5+
[hub_verify_token] => 12345
6+
)

0 commit comments

Comments
 (0)