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

Commit

Permalink
Merge pull request #44 from weslinkde/master
Browse files Browse the repository at this point in the history
New Feature to FIX #39
  • Loading branch information
mahype authored Sep 30, 2018
2 parents fa86b6b + 7d15e04 commit bccae81
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
13 changes: 13 additions & 0 deletions components/admin/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public function admin_menu() {
*/
public function register_settings() {
register_setting( 'fbfpi_options', 'fbfpi_fanpage_id' );
register_setting( 'fbfpi_options', 'fbapp_accesstoken' );
register_setting( 'fbfpi_options', 'fbfpi_fanpage_stream_language' );
register_setting( 'fbfpi_options', 'fbfpi_import_interval' );
register_setting( 'fbfpi_options', 'fbfpi_import_num' );
Expand Down Expand Up @@ -106,6 +107,7 @@ public function admin_page() {
do_settings_sections( 'fbfpi_options' );

$fanpage_id = get_option( 'fbfpi_fanpage_id' );
$fbapp_accesstoken = get_option( 'fbapp_accesstoken' );
$fanpage_stream_language = get_option( 'fbfpi_fanpage_stream_language' );
$import_interval = get_option( 'fbfpi_import_interval' );
$import_num = get_option( 'fbfpi_import_num' );
Expand Down Expand Up @@ -133,6 +135,17 @@ public function admin_page() {
echo '</div>';
echo '</div>';


/**
* fbapp_accesstoken
*/
echo '<div class="fbfpi-form-field">';
echo '<label for="fbapp_accesstoken">' . __( 'Facebook App Access Token', 'facebook-fanpage-import' ) . '</label>';
echo '<div class="input">';
echo '<input type="text" name="fbapp_accesstoken" id="fbapp_accesstoken" value="' . $fbapp_accesstoken . '" /><br /><small>' . __( 'Create a Facebook App and add the aceesstoken here.', 'facebook-fanpage-import' ) . '</small>';
echo '</div>';
echo '</div>';

/**
* Select stream languages
*/
Expand Down
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 bccae81

Please sign in to comment.