function insertAnnotation($req, $connection_name) { $author = $req->getIp(); //$allPostVars = $req->post(); //print_r($allPostVars); //Array ( [sezione] => A [evento] => 1 [valutazione] => A10++ [commento] => Prova ) $commento = $req->post('commento'); $valutazione = $req->post('valutazione'); $sezione = $req->post('sezione'); $evento = $req->post('evento'); if (null != $sezione && null != $evento && is_numeric($evento)) { $eventoNum = intval($evento); if ($eventoNum < 0) { $eventoNum = 0; } if ($eventoNum < 10) { $valutazione = $sezione . '0' . $eventoNum . $valutazione; } else { $valutazione = $sezione . $eventoNum . $valutazione; } } $annotation = new Annotation(array('author' => $author, 'source' => Source::WEB, 'sourceId' => '', 'text' => $valutazione . ' ' . $commento, 'textHtml' => $valutazione . ' ' . $commento, 'hashtags' => array())); $annotation->setConnection($connection_name); $annotation->save(); $result = Parser::parse($valutazione); if ($result != false) { $evaluation = new Evaluation(array('annotation_id' => $annotation->id, 'sessione' => $result->sessione, 'evento' => $result->evento, 'punteggio' => $result->punteggio)); $evaluation->setConnection($connection_name); $evaluation->save(); } }
function feedhistory($connection = 'default', $limit) { $annotations = Annotation::on($connection)->with('Attachments')->where('id', '<', $limit)->orderBy('id', 'desc')->take(20)->get(); Carbon::setToStringFormat(DateTime::ISO8601); $result = []; foreach ($annotations as $annotation) { $result[] = json_decode($annotation->toJson()); } return json_encode($result); }
$testo_tweet = $elem_search->text; if (isset($elem_search->retweeted_status)) { $testo_tweet = 'RT: ' . $elem_search->retweeted_status->text; } if (isset($elem_search->coordinates)) { $point = \GeoJson\GeoJson::jsonUnserialize($elem_search->coordinates); } // Entites https://dev.twitter.com/overview/api/entities $hashtags = []; foreach ($elem_search->entities->hashtags as $ht) { // lo # non c'e' se serve va messo $hashtags[] = $ht->text; } $ann = Annotation::on($connection_name)->where('sourceId', $id_tweet)->get(); if ($ann->count() == 0) { $annotation = new Annotation(array('author' => $nick, 'source' => Source::TWITTER, 'sourceId' => $id_tweet, 'text' => $testo_tweet, 'textHtml' => parseTweet($testo_tweet), 'hashtags' => $hashtags)); $annotation->setConnection($connection_name); $annotation->save(); $result = Parser::parse($testo_tweet); if ($result != false) { $evaluation = new Evaluation(array('annotation_id' => $annotation->id, 'sessione' => $result->sessione, 'evento' => $result->evento, 'punteggio' => $result->punteggio)); $evaluation->setConnection($connection_name); $evaluation->save(); } $imageCount = 0; if (isset($elem_search->entities->media)) { foreach ($elem_search->entities->media as $media) { $imageCount++; $resources[] = $media->media_url; $dataImg = file_get_contents($media->media_url); $filename = basename($media->media_url);