26 public $fbFeedFields =
'picture,message,place,created_time,full_picture,coordinates';
49 $widget = new \YAWK\widget();
68 if (isset($this->fbFeedAppId) && (!empty($this->fbFeedAppId)))
70 if (is_numeric($this->fbFeedAppId))
76 die (
"app ID is set, but not a numeric value! Please check your app ID - it should contain numbers only.");
81 die (
"app ID is not set. Please add your app ID. You can obtain it from http://developers.facebook.com");
87 if (isset($this->fbFeedAccessToken) && (!empty($this->fbFeedAccessToken)))
89 if (is_string($this->fbFeedAccessToken))
95 die (
"Access token is set, but not a string value! Please check your access token.");
100 die (
"Access token is not set. Please add your access token. You can obtain it from http://developers.facebook.com");
105 if (isset($this->fbFeedPageId) && (!empty($this->fbFeedPageId)))
107 if (is_string($this->fbFeedPageId))
113 die (
"Page ID is set, but not a string value! Please check your page ID.");
118 die (
"Page ID is not set. Please add your page ID. The Page ID is: https://www.facebook.com/{YOURPAGEID}");
125 if (isset($this->fbFeedPageId) && (!empty($this->fbFeedPageId)))
132 $this->fbFeedPageId =
'';
136 if (isset($this->fbFeedFields) && (!empty($this->fbFeedFields)))
138 if (empty($this->fbFeedPageId))
140 $this->fbFeedFields =
"?fields={$this->fbFeedFields}";
145 $this->fbFeedFields =
'';
150 $this->jsonLink =
"https://graph.facebook.com/v3.3/{$this->fbFeedGraphRequest}?fields={$this->fbFeedFields}&access_token={$this->fbFeedAccessToken}&limit={$this->fbFeedLimit}";
153 curl_setopt($curl, CURLOPT_URL, $this->jsonLink);
154 curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
156 $this->apiObject = json_decode(curl_exec($curl),
true, 512, JSON_BIGINT_AS_STRING);
161 if (isset($this->apiObject) && (is_array($this->apiObject[
'data']))) {
167 print_r($this->apiObject);
169 die(
'There was an error during the curl process. Please check your facebook connection data.');
175 if (isset($this->apiObject[
'data']) && (!empty($this->apiObject[
'data'])))
197 echo
"Could not retrieve any data from Facebook. Please check your PageID, API request, field and date settings";
215 $this->apiObject[
'data'] = array_reverse($this->apiObject[
'data']);
218 echo
'<div class="row" style="margin:10px;">';
222 die(
'Oops, something went wrong here: NEWS data could not be retrieved.');
230 $this->eventDate = new \DateTime($this->apiObject[
'data'][
$i][
'created_time']);
232 $this->prettyDate = $this->eventDate->format(
'd.m.Y H:i');
234 $now = new \DateTime();
237 $until =
$now->diff($this->eventDate,
true);
240 $eventDateSimple = $this->eventDate->format(
'Y-m-d');
242 $currentDateSimple =
$now->format(
'Y-m-d');
245 if ($this->eventDate >
$now)
256 if ($until->days >= 31 && ($until->days < 365))
264 $duration =
"Monaten";
267 $this->dateString =
"$prepend $until->m $duration";
270 else if ($until->days >= 365)
278 $duration =
"Jahren";
281 $this->dateString =
"$prepend $until->y $duration";
285 else if ($until->days === 14)
287 if ($this->eventDate >
$now)
290 $this->dateString =
"in zwei Wochen";
295 $this->dateString =
"vor zwei Wochen";
298 else if ($until->days >= 8 && ($until->days <= 13))
299 {
if ($this->eventDate >
$now)
302 $this->dateString =
"in knapp zwei Wochen";
307 $this->dateString =
"vor knapp zwei Wochen";
310 else if ($until->days === 7)
311 {
if ($this->eventDate >
$now)
314 $this->dateString =
"in einer Woche";
319 $this->dateString =
"vor einer Woche";
322 else if ($until->days === 2)
324 if ($this->eventDate >
$now)
327 $this->dateString =
"übermorgen";
332 $this->dateString =
"vorgestern";
335 else if ($until->days === 1)
337 if ($this->eventDate >
$now)
340 $this->dateString =
"<span class=\"".$this->fbEventsDatewordCss.
"\">morgen</span>";
345 $this->dateString =
"<span class=\"".$this->fbEventsDatewordCss.
"\">gestern</span>";
349 else if ($eventDateSimple == $currentDateSimple)
351 $this->dateString =
"<span class=\"".$this->fbEventsDatewordCss.
"\">HEUTE !</span>";
354 {
if ($this->eventDate >
$now)
357 $this->dateString =
"$prepend $until->d Tagen";
362 if ($until->d === 0 && ($until->m === 0))
364 $this->dateString =
"gestern";
375 $duration =
"Monaten";
379 $this->dateString =
"$prepend $until->m $duration";
383 $this->dateString =
"$prepend $until->d Tagen";
389 if (!empty($this->apiObject[
'data'][
$i][
'message']))
391 $this->message = $this->apiObject[
'data'][
$i][
'message'];
398 if (!empty($this->apiObject[
'data'][
$i][
'full_picture']))
400 $this->picture =
'<img src="'.$this->apiObject[
'data'][
$i][
'full_picture'].
'" class="card-img-top protected">';
407 if (isset($this->apiObject[
'data'][
$i][
'place'][
'name']))
409 $this->place =
"@ ".$this->apiObject[
'data'][
$i][
'place'][
'name'];
427 echo
'<div class="col-lg-4 animate" data-fx="fadeIn">';
428 echo
'<div class="card">
429 <div class="card-header"><h5 class="card-title">'.$this->apiObject[
'data'][
$i][
'from'][
'name'].
'
430 <small class="text-muted">'.$this->place.
'</small></h5>
431 <h5 class="card-subtitle mb-2 text-muted"><small>'.$this->dateString.
'</small></h5>
434 <div class="card-body">
435 <p class="card-text">'.$this->message.
'</p>
440 echo
'<br><br></div>';
if(isset($_POST['save'])) $settings