public function add_json_string($name, $filename, $content) { return $this->build_attachment($name, $filename, $content, 'application/json', strlen($content)); }
/** * Parses the API response and checks for errors. * TODO The exporter has an abstracted article class. Should we have * something similar here? That way this method could live there. * * @param string $article * @param array $bundles * @param array $meta * @return string * @since 0.2.0 */ private function build_content($article, $bundles = array(), $meta = null) { $bundles = array_unique($bundles); $content = ''; if ($meta) { $content .= $this->mime_builder->add_metadata($meta); } $content .= $this->mime_builder->add_json_string('my_article', 'article.json', $article); foreach ($bundles as $bundle) { $content .= $this->mime_builder->add_content_from_file($bundle); } $content .= $this->mime_builder->close(); return $content; }