Ejemplo n.º 1
0
 public function getPersonalFeed($user)
 {
     $token = $user->getAuthorizedToken($this->getName());
     $this->token = $token;
     $feeds = [];
     $taggedPosts = $this->facebook->get('/me/tagged?limit=10&fields=message,likes,link,description,caption,created_time,from,picture,source&', $token);
     $likes = $this->facebook->get("/me/likes?limit=10", $token);
     $likePosts = [];
     $body = $likes->getDecodedBody();
     foreach ($body["data"] as $site) {
         $likePosts[] = $this->facebook->get($site["id"] . "/posts?limit=5&fields=message,likes,link,description,caption,created_time,from,picture,source", $token);
     }
     $decodedBody = $taggedPosts->getDecodedBody();
     if (!empty($decodedBody["data"])) {
         $feeds[] = $this->encodeJSON($decodedBody);
     }
     foreach ($likePosts as $site) {
         $decodedBody = $site->getDecodedBody();
         if (!empty($decodedBody["data"])) {
             $feeds[] = $this->encodeJSON($site->getDecodedBody());
         }
     }
     if (empty($feeds)) {
         return null;
     }
     if (!empty($feeds)) {
         $feed = [];
         foreach ($feeds as $array) {
             $feed = array_merge($feed, $array);
         }
         $this->token = null;
         return json_encode(['name' => parent::getName(), 'icon' => parent::getIcon(), 'color' => parent::getColor(), 'feed' => $feed]);
     }
 }
Ejemplo n.º 2
0
 public function encodeJSON($json)
 {
     $data = json_decode($json, true);
     $feed = [];
     foreach (array_slice($data["threads"], 1) as $gitem) {
         if ($gitem["posts"][0]["resto"] == 0) {
             $item = [];
             if (isset($gitem["posts"][0]["sub"])) {
                 $item["title"] = $gitem["posts"][0]["sub"];
             }
             $item["author"] = null;
             if (isset($gitem["posts"][0]["name"])) {
                 $item["author"] = $gitem["posts"][0]["name"];
             }
             $item["text"] = $gitem["posts"][0]["com"];
             $item["link"] = "https://boards.4chan.org/news/thread/" . $gitem["posts"][0]["no"];
             if (isset($gitem["posts"][0]["tim"])) {
                 $item["media"] = "https://i.4cdn.org/news/" . $gitem["posts"][0]["tim"] . "" . $gitem["posts"][0]["ext"];
                 $item["type"] = 'image';
                 if ($gitem["posts"][0]["ext"] == ".webm") {
                     $item["type"] = 'video';
                 }
             } else {
                 $item["type"] = 'text';
             }
             $item["createdTime"] = parent::formatTime($gitem["posts"][0]["time"]);
             array_push($feed, $item);
         }
     }
     $newJSON = array('name' => parent::getName(), 'icon' => parent::getIcon(), 'color' => parent::getColor(), 'customIcon' => true, 'feed' => $feed);
     return json_encode($newJSON);
 }
Ejemplo n.º 3
0
 public function encodeJSON($json)
 {
     $feed = [];
     foreach ($json->data as $media) {
         $data = [];
         $data['type'] = $media->type;
         $data['tags'] = $media->tags;
         $data['title'] = null;
         $data['createdTime'] = parent::formatTime($media->created_time);
         if (isset($media->caption, $media->caption->text)) {
             $data['text'] = $media->caption->text;
         }
         if (!isset($media->caption, $media->caption->text)) {
             $data['text'] = '';
         }
         $data['link'] = $media->link;
         $data['author'] = $media->user->username;
         $data['authorPicture'] = $media->user->profile_picture;
         $data['numberOfLikes'] = $media->likes->count;
         if ($media->type === 'image') {
             $data['media'] = $media->images->standard_resolution->url;
             $data['thumb'] = $media->images->thumbnail->url;
         } elseif ($media->type === 'video') {
             $data['media'] = $media->videos->standard_resolution->url;
         }
         $feed[] = $data;
     }
     $newJSON = array('name' => parent::getName(), 'icon' => parent::getIcon(), 'color' => parent::getColor(), 'feed' => $feed);
     return json_encode($newJSON);
 }
Ejemplo n.º 4
0
 public function encode($resource)
 {
     $parser = $this->reader->getParser($resource->getUrl(), $resource->getContent(), $resource->getEncoding());
     $data = $parser->execute();
     $feed = [];
     if (isset($data->items) && isset($data->items[0]) && $data->items[0]->hasNamespace('News')) {
         foreach ($data->items as $value) {
             $item = [];
             $item['type'] = 'image';
             $item['media'] = $value->getTag('News:Image')[0];
             $item['author'] = $value->getTag('News:Source')[0];
             $item['title'] = $value->getTag('title')[0];
             $item['text'] = $value->getTag('description')[0];
             $item['createdTime'] = parent::formatTime(strtotime($value->getTag('pubDate')[0]));
             $item['link'] = $value->getTag('link')[0];
             $feed[] = $item;
         }
     }
     return json_encode(array('name' => parent::getName(), 'icon' => parent::getIcon(), 'color' => parent::getColor(), 'customIcon' => true, 'feed' => $feed));
 }
Ejemplo n.º 5
0
 public function encodeJSON($json)
 {
     $data = json_decode($json, true);
     $feed = [];
     foreach ($data["data"] as $gitem) {
         $item = [];
         $item["title"] = $gitem["caption"];
         $item["author"] = "9GAG";
         $item["numberOfLikes"] = $gitem["votes"]["count"];
         $item["link"] = $gitem["link"];
         if ($gitem["media"] != false) {
             $item["type"] = "video";
             $item["media"] = $gitem["media"]["webm"];
         } else {
             $item["type"] = "image";
             $item["media"] = $gitem["images"]["large"];
         }
         $item["createdTime"] = "";
         $item["thumb"] = $gitem["images"]["small"];
         $feed[] = $item;
     }
     $newJSON = array('name' => parent::getName(), 'icon' => parent::getIcon(), 'color' => parent::getColor(), 'customIcon' => true, 'feed' => $feed);
     return json_encode($newJSON);
 }
Ejemplo n.º 6
0
 public function encodeJSON($json)
 {
     $data = json_decode($json, true);
     $tempSong = [];
     $feed = [];
     if ($this->public) {
         foreach ($data["collection"] as $song) {
             $tempSong["text"] = $song["track"]["description"];
             $tempSong["title"] = $song["track"]["title"];
             $tempSong["author"] = $song["track"]["user"]["username"];
             $tempSong["authorPicture"] = $song["track"]["user"]["avatar_url"];
             $tempSong["numberOfLikes"] = $song["track"]["likes_count"];
             $tempSong["link"] = $song["track"]["permalink_url"];
             $tempSong["type"] = "audio";
             $tempSong["createdTime"] = parent::formatTime(strtotime($song["track"]["created_at"]));
             $tempSong["media"] = $song["track"]["uri"] . '?client_id=d08c99a67fa0518806f5fe1f4bf36792';
             $tempSong["thumb"] = $song["track"]["artwork_url"];
             $match = [];
             preg_match_all('/(\\"[A-Za-z0-9\\s]+\\"|[A-Za-z0-9]+)/', $song["track"]["tag_list"], $match);
             $tempSong["tags"] = null;
             for ($i = 1; $i < count($match); $i++) {
                 $tempSong["tags"] = str_replace("\"", "", $match[$i]);
             }
             $feed[] = $tempSong;
             $tempSong = [];
         }
     }
     if (!$this->public) {
         foreach ($data as $song) {
             $tempSong["text"] = $song["description"];
             $tempSong["title"] = $song["title"];
             $tempSong["author"] = $song["user"]["username"];
             $tempSong["authorPicture"] = $song["user"]["avatar_url"];
             $tempSong["numberOfLikes"] = null;
             $tempSong["link"] = $song["permalink_url"];
             $tempSong["type"] = "audio";
             $tempSong["createdTime"] = parent::formatTime(strtotime($song["created_at"]));
             $tempSong["media"] = $song["stream_url"] . '?client_id=d08c99a67fa0518806f5fe1f4bf36792';
             $tempSong["thumb"] = $song["artwork_url"];
             $tempSong["tags"] = null;
             $match = [];
             preg_match_all('/(\\"[A-Za-z0-9\\s]+\\"|[A-Za-z0-9]+)/', $song["track"]["tag_list"], $match);
             $tempSong["tags"] = null;
             for ($i = 1; $i < count($match); $i++) {
                 $tempSong["tags"] = $match[$i];
             }
             $feed[] = $tempSong;
             $tempSong = [];
         }
     }
     $newJSON = array('name' => parent::getName(), 'icon' => parent::getIcon(), 'color' => parent::getColor(), 'feed' => $feed);
     return json_encode($newJSON);
 }
Ejemplo n.º 7
0
 public function encodeJSON($json)
 {
     $feed = [];
     foreach ($json->items as $item) {
         $data = [];
         $data['type'] = "video";
         $data['tags'] = $item->snippet->tags;
         $data['createdTime'] = parent::formatTime(strtotime($item->snippet->publishedAt));
         if (isset($item->id->videoId)) {
             $id = $item->id->videoId;
         }
         if (!isset($item->id->videoId)) {
             $id = $item->id;
         }
         $data['link'] = "https://www.youtube.com/watch?v=" . $id;
         $data['author'] = $item->snippet->channelTitle;
         $profile = null;
         try {
             $channel = $this->youtube->channels->listChannels("contentDetails", ["id" => $item->snippet->channelId]);
             if (isset($channel->items[0]->contentDetails->googlePlusUserId)) {
                 $profile = $this->googlePlus->people->get($channel->items[0]->contentDetails->googlePlusUserId);
             }
         } catch (\Google_Service_Exception $e) {
             print_r($e->getMessage());
         }
         $data['authorPicture'] = null;
         if (isset($profile->image)) {
             $data['authorPicture'] = $profile->image->url;
         }
         $data['numberOfLikes'] = null;
         if (isset($item->statistics)) {
             $data['numberOfLikes'] = intval($item->statistics->likeCount);
         }
         $data['media'] = "https://www.youtube.com/embed/" . $id;
         $data['thumb'] = $item->snippet->thumbnails->default->url;
         $data['title'] = $item->snippet->title;
         $data['text'] = $item->snippet->description;
         $feed[] = $data;
     }
     $newJSON = array('name' => parent::getName(), 'icon' => parent::getIcon(), 'color' => parent::getColor(), 'feed' => $feed);
     return json_encode($newJSON);
 }