Apple_Push_API\MIME_Builder::add_metadata PHP Method

add_metadata() public method

Add metadata to the MIME request.
public add_metadata ( mixed $meta ) : string
$meta mixed
return string
    public function add_metadata($meta)
    {
        $attachment = '--' . $this->boundary . $this->eol;
        $attachment .= 'Content-Type: application/json' . $this->eol;
        $attachment .= 'Content-Disposition: form-data; name=metadata' . $this->eol . $this->eol;
        $attachment .= json_encode($meta) . $this->eol;
        $this->debug_content .= $attachment;
        return $attachment;
    }

Usage Example

Beispiel #1
0
 /**
  * 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;
 }
All Usage Examples Of Apple_Push_API\MIME_Builder::add_metadata