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>
0 commit comments