29 public $fbExampleFields =
'id,name,description,place,start_time,cover,maybe_count,attending_count,is_canceled';
51 $widget = new \YAWK\widget();
70 if (isset($this->fbExampleAppId) && (!empty($this->fbExampleAppId)))
72 if (is_numeric($this->fbExampleAppId))
78 die (
"app ID is set, but not a numeric value! Please check your app ID - it should contain numbers only.");
83 die (
"app ID is not set. Please add your app ID. You can obtain it from http://developers.facebook.com");
89 if (isset($this->fbExampleAccessToken) && (!empty($this->fbExampleAccessToken)))
91 if (is_string($this->fbExampleAccessToken))
97 die (
"Access token is set, but not a string value! Please check your access token.");
102 die (
"Access token is not set. Please add your access token. You can obtain it from http://developers.facebook.com");
107 if (isset($this->fbExamplePageId) && (!empty($this->fbExamplePageId)))
109 if (is_string($this->fbExamplePageId))
130 if ($this->jsSDKLoaded ==
'false')
136 window.fbAsyncInit = function() {
138 appId : '" . $this->fbExampleAppId .
"',
142 FB.AppEvents.logPageView();
146 var js, fjs = d.getElementsByTagName(s)[0];
147 if (d.getElementById(id)) {return;}
148 js = d.createElement(s); js.id = id;
149 js.src = \"https://connect.facebook.net/en_US/sdk.js\";
150 fjs.parentNode.insertBefore(js, fjs);
151 }(document, 'script', 'facebook-jssdk'));
153 $this->jsSDKLoaded =
'true';
157 die (
"unable to include facebook js SDK - checkAppId failed. Please check your app ID in the widget settings!");
166 if ($this->fbExampleType ==
"all")
169 $this->sinceDate =
date(
'Y-01-01', strtotime(
'-' . $this->fbExampleYearRange .
' years'));
170 $this->untilDate =
date(
'Y-01-01', strtotime(
'+' . $this->fbExampleYearRange .
' years'));
172 elseif ($this->fbExampleType ==
"future")
175 $this->sinceDate =
date(
'Y-m-d');
176 $this->untilDate =
date(
'Y-12-31', strtotime(
'+' . $this->fbExampleYearRange .
' years'));
178 elseif ($this->fbExampleType ==
"past")
181 $this->sinceDate =
date(
'Y-01-01', strtotime(
'-' . $this->fbExampleYearRange .
' years'));
182 $this->untilDate =
date(
'Y-m-d');
187 $this->sinceDate =
date(
'Y-m-d');
188 $this->untilDate =
date(
'Y-12-31', strtotime(
'+' . $this->fbExampleYearRange .
' years'));
192 if (isset($this->fbExampleStartDate) && (!empty($this->fbExampleStartDate))
193 && (isset($this->fbExampleEndDate) && (!empty($this->fbExampleEndDate))))
195 $this->sinceDate =
date($this->fbExampleStartDate);
196 $this->untilDate =
date($this->fbExampleEndDate);
200 $since_unix_timestamp = strtotime($this->sinceDate);
201 $until_unix_timestamp = strtotime($this->untilDate);
203 if (isset($this->fbExamplePageId) && (!empty($this->fbExamplePageId)))
206 $pageIdMarkup =
"{$this->fbExamplePageId}";
210 $this->fbExamplePageId =
'';
213 if (isset($this->fbExampleFields) && (!empty($this->fbExampleFields)))
215 $fieldsMarkup =
"&fields={$this->fbExampleFields}";
216 if (empty($this->fbExamplePageId))
218 $fieldsMarkup =
"?fields={$this->fbExampleFields}";
228 $json_link =
"https://graph.facebook.com/v3.1/{$this->fbExamplePageId}{$this->fbExampleGraphRequest}?access_token={$this->fbExampleAccessToken}&since={$since_unix_timestamp}&until={$until_unix_timestamp}" . $fieldsMarkup .
"";
230 $json = file_get_contents($json_link);
233 return $this->apiObject = json_decode($json,
true, 512, JSON_BIGINT_AS_STRING);
238 if (isset($this->apiObject[
'data']) && (!empty($this->apiObject[
'data'])))
260 echo
"Could not retrieve any data from Facebook. Please check your PageID, API request, field and date settings";
271 foreach ($this->apiObject[
'data'] as $property =>
$value) {
272 echo
"<b>$property </b>: $value<br>";
274 foreach (
$value as $entry => $key) {
276 echo
"$entry : $key<br>";
278 if (is_array($key)) {
279 foreach ($key as $p => $v) {
280 echo
" $p : $v<br>";
282 foreach ($v as $a => $b) {
283 echo
" $a : $b<br>";
297 if (isset($this->apiObject[
'data']) && (!empty($this->apiObject))) {
298 echo
"<h1>Facebook Photo Albums</h1>";
300 foreach ($this->apiObject[
'data'] as $property =>
$value)
302 if (
$value[
'name'] !=
"//Profile Pictures"
306 $fn =
$value[
'picture'][
'data'][
'url'];
307 echo
"<div class=\"col-md-2 text-center\">
308 <img src=\"$fn\" style=\"width:200px;\" class=\"img-responsive hvr-grow\"><h3>$value[name]
309 <small><i>($value[count])</i></small></h3><br>
if(isset($_POST['save'])) $settings