From 7d15e04087553b95f231f7f1eb1cfc7c8c408d47 Mon Sep 17 00:00:00 2001 From: Gisella Klemm <37448213+KathlynnS@users.noreply.github.com> Date: Thu, 27 Sep 2018 10:59:40 +0200 Subject: [PATCH] Update facebook.php - use the new access token option value for requests - show errors to the user if a error occurs (e.g. app not yet approved, request limit reached etc.) --- components/import/facebook.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/components/import/facebook.php b/components/import/facebook.php index 36f75ba..d881de0 100644 --- a/components/import/facebook.php +++ b/components/import/facebook.php @@ -56,7 +56,7 @@ class FacebookFanpageConnect { * @since 1.0.0 */ function __construct( $page_id, $access_token = '', $locale = 'en_EN' ) { - $this->access_token = '1412978082344911|a7f5722a2b02f24aad0cda61ae5c4fe9'; + $this->access_token = get_option( 'fbapp_accesstoken' ); $this->graph_url = 'https://graph.facebook.com/v2.7/'; $this->locale = $locale; @@ -117,8 +117,20 @@ private function fetch_data( $url ) { curl_setopt( $con, CURLOPT_SSL_VERIFYPEER, false ); $data = curl_exec( $con ); - + + $responseCode = curl_getinfo($con, CURLINFO_HTTP_CODE); curl_close( $con ); + + + if ($responseCode >= 400) { + echo "\n
HTTP Error: " . $responseCode; + echo "\n
Result-Body: "; + print_r($data); + echo "\n
\n
"; + } + + + } elseif ( ini_get( 'allow_url_fopen' ) === true || ini_get( 'allow_url_fopen' ) == 1 ) { $data = @file_get_contents( $url ); } else {