public function sendTweet($msg) { $input = array('msg' => $msg); $v = new InputValidator($input); $v->string()->validate('msg', 'Mensagem'); $v->throwException(); $consumer_key = $this->_sm_credentials->row['tw_consumer_key']; $consumer_secret = $this->_sm_credentials->row['tw_consumer_secret']; $access_token = $this->_sm_credentials->row['tw_access_token']; $access_secret = $this->_sm_credentials->row['tw_access_secret']; //_# ENVIA O TWEET try { $twitter = new Twitter($consumer_key, $consumer_secret, $access_token, $access_secret); $twitter->send($msg); } catch (Exception $e) { if ($e->getMessage() == 'Status is a duplicate.') { throw new Exception('Essa mensagem já foi publicada anteriormente.'); } else { throw new Exception('Erro ao enviar tweet: ' . $e->getMessage()); } } $f = new TableFilter($this->_table, $input); $f->newId()->filter('id_tweet'); $f->timestamp()->filter('date'); $f->string()->filter('msg'); // $this->_dao->insert($this->_table); //_# AVISA O MODEL $this->_model->sentTweet($this->_table->id_tweet); }
public function insert($input) { $input['file'] = array($input['file']); $v = new InputValidator($input); $has_file = $v->upload()->validate('file', 'Foto'); $v->throwException(); // $f = new TableFilter($this->_table, $input); $f->labelCredit()->filter('file'); $f->newId()->filter($this->_id_photo_item); $f->string()->filter($this->_id_photo); $f->string()->filter('sequence'); // $mf = new MoveFiles(); $f->uploaded("/system/uploads/{$this->_photo}/{$input[$this->_id_photo]}/{$this->_photo_item}/{$this->getId()}/file", $has_file, $mf)->filter('file'); // $mf->move(); $this->_dao->insert($this->_table); }
/** * * @param type $input array( * 'url' => '', * ' name' => '', * 'title' => '', * 'parent_table' => '', * 'parent_id_field' => '', * 'parent_id_value' => '', * 'id_issuu' => '', * 'delete_previous' => '' * ) */ public function insertComplete($input) { if ($input['delete_previous']) { $this->deleteComplete($input); } // insere na api $response = $this->_api->document_url_upload($input['url'], $input['name'], $input['title']); // gera embed $embed = $this->_api->document_embed_add($response['document_id'], 500, 500); // insere na tabela issuu $f = new TableFilter($this->_table, array('document_id' => $response['document_id'], 'name' => $response['name'], 'link' => $response['link'], 'embed_id' => $embed['id'], 'data_config_id' => $embed['dataConfigId'])); $f->newId()->filter('id_issuu'); $f->string()->filter('name'); $f->string()->filter('link'); $f->string()->filter('document_id'); $f->string()->filter('embed_id'); $f->string()->filter('data_config_id'); $this->_dao->insert($this->_table); // atualiza tabela parent com o id da tabela issuu $parent_table = new Table($input['parent_table']); $parent_table->id_issuu = $this->getId(); $this->_dao->update($parent_table, array("{$input['parent_id_field']} = ?" => $input['parent_id_value'])); }
public function insertFromLink($link) { $response_text = file_get_contents("http://api.soundcloud.com/resolve.json?url={$link}&client_id={$this->_sm_credentials->row['sc_client_id']}"); $response_json = json_decode($response_text); if (json_last_error()) { throw new Exception('Não foi possível converter pra JSON: ' . $response_text); } $track_id = $response_json->id; $permalink_url = $response_json->permalink_url; $f = new TableFilter($this->_table, array('track_id' => $track_id, 'track_permalink' => $permalink_url)); $f->newId()->filter('id_soundcloud'); $f->string()->filter('track_id'); $f->string()->filter('track_permalink'); $this->_dao->insert($this->_table); return $this->_table->id_soundcloud; }
public function post($input) { try { $v = new InputValidator($input); $v->string()->validate('name', 'Nome'); $v->string()->validate('link', 'Link'); $v->throwException(); // $fileSystem = new FileSystem('tokens'); $facebookKey = new SocialKeys(); $facebookKey->setClientId(FACEBOOK_CLIENT_ID); $facebookKey->setClientSecret(FACEBOOK_CLIENT_SECRET); $facebookKey->setRedirectUri(FACEBOOK_REDIRECT_URL); $facebookAuth = new FacebookAuth($facebookKey, $fileSystem); $fb = new \Facebook\Facebook(['app_id' => FACEBOOK_CLIENT_ID, 'app_secret' => FACEBOOK_CLIENT_SECRET, 'default_graph_version' => 'v2.7', 'default_access_token' => $facebookAuth->getToken()['access_token']]); $facebookPost = new \dinsocial\Facebook\PageFeed($fb); $id_post = $facebookPost->postPageFeed(FACEBOOK_PAGE_ID, $input['link'], $input['name'], $input['picture'], $input['description'], $input['message']); if ($id_post) { $f = new TableFilter($this->_table, $input); $f->newId()->filter('id_facepost'); $f->timestamp()->filter('date'); $f->string()->filter('name'); $f->string()->filter('link'); $f->string()->filter('picture'); $f->string()->filter('description'); $f->string()->filter('message'); // $this->_dao->insert($this->_table); //_# AVISA O MODEL $this->_model->sentPost($this->_table->id_facepost); } } catch (Exception $e) { return $e->getMessage(); } }