Skip to content

Commit

Permalink
import image title
Browse files Browse the repository at this point in the history
  • Loading branch information
seibtph authored and Philipp Seibt committed Sep 19, 2019
1 parent 77e96d0 commit 9b1412e
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/NewsListener/CronListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ public function getFbPosts()

if($post['from']['name'] != "") {

$imageSrc = $this->getFbAttachments($fb, $id = $post['id'], $accessToken, $imgPath);
$image = $this->getFbAttachments($fb, $id = $post['id'], $accessToken, $imgPath);
$imageSrc = $image['src'];
$imageTitle = $image['title'];

// set variables
if(strpos($post['message'],"\n")) {
Expand Down Expand Up @@ -112,7 +114,13 @@ public function getFbPosts()
}
$objNews->tstamp = time();
$objNews->headline = $title;
$objNews->teaser = $message;

if($message == "" && $imageTitle != "") {
$objNews->teaser = $imageTitle;
} else {
$objNews->teaser = $message;
}

$objNews->date = $timestamp;
$objNews->time = $timestamp;
$objNews->published = 1;
Expand Down Expand Up @@ -192,7 +200,12 @@ private function getFbAttachments($fb,$id,$accessToken, $imgPath) {
$file->close();
}

return $imageSrc;
$image = [
'src' => $arrMedia['media']['image']['src'],
'title' => $arrMedia['title']
];

return $image;
} catch(Facebook\Exceptions\FacebookResponseException $e) {
echo 'Graph returned an error: ' . $e->getMessage();
exit;
Expand Down

0 comments on commit 9b1412e

Please sign in to comment.