$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); //"http://pbs.twimg.com/media/CPbPvS6UkAE7dYw.jpg", if ('' == trim($filename)) { $url = $media->expanded_url; $parts = parse_url($url); // /Nonsprecare/status/645894353769111552/photo/1 echo $parts['path']; $str = explode('/', $parts['path']); $filename = $str[4]; } $filesystem->put($id_tweet . '/' . $filename, $dataImg); $attachments = new Attachment(array('annotation_id' => $annotation->id, 'source' => Source::TWITTER, 'fileName' => $filename, 'filePath' => $id_tweet . '/' . $filename)); $attachments->setConnection($connection_name); $attachments->save(); } } } } $filesystem->put('last.tweet', $lastId); } catch (\Exception $e) { $log->addError($e->getFile() . ' on ' . $e->getLine() . ' ' . ' because : ' . $e->getMessage()); }