static function add_instagram_photo()
 {
     $language = $_POST['language'];
     $code = $_POST['embedCode'];
     $dirID = $_POST['dirID'];
     $instagram = new Instagram(array('apiKey' => 'be70ed08fc66446ba46b4797870a4c62', 'apiSecret' => '3486b765962d40aa8037c4cc0b37ff8c', 'apiCallback' => 'YOUR_APP_CALLBACK'));
     $api = file_get_contents("http://api.instagram.com/oembed?url={$code}");
     $apiObj = json_decode($api, true);
     $media_id = $apiObj['media_id'];
     $data = $instagram->getMedia($media_id);
     //        MainController::printArray($data);
     if ($data->data->type == "video") {
         $url = $data->data->videos->standard_resolution->url;
         $height = $data->data->videos->standard_resolution->height;
         $width = $data->data->videos->standard_resolution->width;
         $width = $data->data->videos->standard_resolution->width;
     } else {
         if ($data->data->type == "image") {
             $url = $data->data->images->standard_resolution->url;
             $width = $data->data->images->standard_resolution->width;
             $height = $data->data->images->standard_resolution->height;
         }
     }
     $date = date('d.m.Y', $data->data->created_time);
     $caption = $data->data->caption->text;
     $type = $data->data->type;
     Dispatcher::$mysqli->query("insert into instagram (code, direction_id, type, width, height, caption, created_time) " . "values ('{$url}', '{$dirID}', '{$type}', '{$width}', '{$height}', '{$caption}', '{$date}')");
 }
 /**
  * validateMedia it controls the input is numeric
  * and connect with Instagram API for location data
  *
  * @param  int $media_id
  * @return array response
  *         array response['location'] || response['error']
  *         int   response['status']
  **/
 public function validateMedia($media_id)
 {
     if (!empty((int) $media_id)) {
         $instagram = $this->instagram->getMedia($media_id);
         if (!empty($instagram)) {
             if (empty($instagram->meta->error_type)) {
                 $response = array('location' => $instagram->data->location, 'status' => 200);
             } else {
                 $response = array('error' => array('error' => $instagram->meta->error_type, 'message' => $instagram->meta->error_message), 'status' => 409);
             }
         } else {
             $response = array('error' => array('error' => self::DATA_NULL, 'message' => self::DATA_NULL_MESSAGE), 'status' => 409);
         }
     } else {
         $response = array('error' => array('error' => self::ERROR_API, 'message' => self::ERROR_API_MESSAGE), 'status' => 409);
     }
     return $response;
 }