Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

Commit

Permalink
Update facebook.php
Browse files Browse the repository at this point in the history
- 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.)
  • Loading branch information
KathlynnS authored Sep 27, 2018
1 parent d2d18e3 commit 7d15e04
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions components/import/facebook.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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<br>HTTP Error: " . $responseCode;
echo "\n<br>Result-Body: ";
print_r($data);
echo "\n<br>\n<br>";
}



} elseif ( ini_get( 'allow_url_fopen' ) === true || ini_get( 'allow_url_fopen' ) == 1 ) {
$data = @file_get_contents( $url );
} else {
Expand Down

0 comments on commit 7d15e04

Please sign in to comment.