Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $access_token = '';
- $api_url = 'https://graph.facebook.com/v6.0/?id=' . urlencode( $_POST['surl'] ) . '&fields=engagement&access_token=' . $access_token;
- $fb_connect = curl_init(); // initializing
- curl_setopt( $fb_connect, CURLOPT_URL, $api_url );
- curl_setopt( $fb_connect, CURLOPT_RETURNTRANSFER, 1 ); // return the result, do not print
- curl_setopt( $fb_connect, CURLOPT_TIMEOUT, 20 );
- $json_return = curl_exec( $fb_connect ); // connect and get json data
- curl_close( $fb_connect ); // close connection
- $body = json_decode( $json_return );
- echo $body->engagement->share_count;
- return intval( $body->engagement->share_count );
Add Comment
Please, Sign In to add comment