yii\httpclient\Client::post PHP Method

post() public method

Creates 'POST' request.
public post ( string $url, array | string $data = null, array $headers = [], array $options = [] ) : Request
$url string target URL.
$data array | string if array - request data, otherwise - request content.
$headers array request headers.
$options array request options.
return Request request instance.
    public function post($url, $data = null, $headers = [], $options = [])
    {
        return $this->createRequestShortcut('post', $url, $data, $headers, $options);
    }

Usage Example

 /**
  * @inheritDoc
  */
 public function export()
 {
     $response = $this->httpClient->post($this->webhookUrl, Json::encode($this->getPayload()), ['Content-Type: application/json; charset=UTF-8'])->send();
     if (!$response->getIsOk()) {
         throw new InvalidValueException("Unable to send logs to Slack: {$response->getContent()}", (int) $response->getStatusCode());
     }
 }
All Usage Examples Of yii\httpclient\Client::post