Apple_Push_API\Request\Request::post PHP Метод

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

Sends a POST request with the given article and bundles.
С версии: 0.2.0
public post ( string $url, string $article, array $bundles = [], array $meta = null ) : mixed
$url string
$article string
$bundles array
$meta array
Результат mixed
    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);
    }

Usage Example

 /**
  * Send a post request.
  *
  * @since 0.2.0
  * @param string $url
  * @param string $article
  * @param array $bundles
  * @param array $meta
  * @return object
  * @access private
  */
 private function send_post_request($url, $article, $bundles, $meta = null)
 {
     return $this->request->post($url, $article, $bundles, $meta);
 }