Apple_Push_API\MIME_Builder::get_debug_content PHP Метод

get_debug_content() публичный Метод

Gets the debug version of the MIME content
public get_debug_content ( array $args ) : string
$args array
Результат string
    public function get_debug_content($args)
    {
        $content = '';
        // Parse the header from the args and convert it into the format
        // that would actually be sent to the API.
        if (!empty($args['headers']) && is_array($args['headers'])) {
            foreach ($args['headers'] as $key => $value) {
                $content .= sprintf('%s: %s%s', $key, $value, $this->eol);
            }
        }
        $content .= $this->eol . $this->debug_content;
        return $content;
    }

Usage Example

Пример #1
0
 /**
  * Sends a POST request with the given article and bundles.
  *
  * @param string $url
  * @param string $article
  * @param array $bundles
  * @param array $meta
  * @return mixed
  * @since 0.2.0
  */
 public function post($url, $article, $bundles = array(), $meta = null)
 {
     // Assemble the content to send
     $content = $this->build_content($article, $bundles, $meta);
     // Build the post request args
     $args = array('headers' => array('Authorization' => $this->sign($url, 'POST', $content), 'Content-Length' => strlen($content), 'Content-Type' => 'multipart/form-data; boundary=' . $this->mime_builder->boundary()), 'body' => $content);
     // Allow filtering and merge with the default args
     $args = apply_filters('apple_news_post_args', wp_parse_args($args, $this->default_args));
     // Perform the request
     $response = wp_safe_remote_post(esc_url_raw($url), $args);
     // Build a debug version of the MIME content for the debug email
     $debug_mime_request = $this->mime_builder->get_debug_content($args);
     // Parse and return the response
     return $this->parse_response($response, true, 'post', $meta, $bundles, $article, $debug_mime_request);
 }