Esempio n. 1
0
 public static function allChannels()
 {
     $ch = self::all();
     $all = array();
     foreach ($ch as $c) {
         $fch = Helper::getChannel($c->id);
         if ($fch) {
             $all[] = $fch;
         }
     }
     return $all;
 }
Esempio n. 2
0
 public function publish($data)
 {
     try {
         $img = parse_url($data['picture']);
         $link = Helper::sortUrl($data['link']);
         $query = array('status' => $data['name'] . ' ' . $link);
         if (file_exists(public_path($img['path']))) {
             $uploaded_media = Social::Twitter()->uploadMedia(['media' => File::get(public_path($img['path']))]);
             $query['media_ids'] = $uploaded_media->media_id_string;
         }
         $res = Social::Twitter()->postTweet($query);
         return array('status' => true);
     } catch (\Exception $e) {
         return array('status' => false, 'error' => $e->getMessage());
     }
 }
 public function setPublish($id)
 {
     $post = \Post::findOrFail($id);
     //Conseguimos el canal puesto como principal
     if ($post->status == 1) {
         return Redirect::back()->with('error', 'Ya ha sido publicado con exito anteriormente');
     }
     $channel = Helper::getChannel($post->channel_id);
     $data = array('name' => $post->title, 'link' => $post->link, 'description' => strip_tags(HTML::decode($post->text)), 'picture' => $post->img);
     $res = $channel->Publish($data);
     if (!$res['status']) {
         $post->status = 5;
         $post->result_post = $res['error'];
         $post->save();
         return Redirect::back()->with('error', $res['error']);
     } else {
         $post->status = 1;
         $post->result_post = $res['status'];
         $post->channel_id = $channel->id;
         $post->save();
         return Redirect::back()->with('message', 'Publicado con éxito');
     }
     // die($post->result_status);
 }
Esempio n. 4
0
 public function channel()
 {
     return Helper::getChannel($this->channel_id);
 }
Esempio n. 5
0
 public function getTest()
 {
     if (Input::get('id_channel')) {
         $ch = Helper::getChannel(Input::get('id_channel'));
         return $ch->getTest();
     }
 }