将卷曲转换为 wp_remote_post

Convert curl to wp_remote_post

谁能帮我把下面的 curl 命令转换成 wp_remote_post。

        $ServerParam = 'VERSION=1.00&PWD='.$this->password.'&ID='
            .$this->id.'&KEY='.$this->key.'&HASH='.$sHash;

        $options = array
        (
            CURLOPT_URL            => $this->api_url,
            CURLOPT_POST           => true,
            CURLOPT_POSTFIELDS     => $ServerParam ,
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_SSL_VERIFYHOST => false
        );

        $curl = curl_init();
        curl_setopt_array($curl, $options);
        $response = curl_exec($curl);
        curl_close($curl);

经过几个小时的尝试,这段代码对我有用。

         $body = array(
            'VERSION'       => '1.00',
            'PWD'           => $this->password,
            'ID'            => $this->id,
            'KEY'           => $this->key,
            'HASH'          => $sHash
        );

        $args = array(
            'body'        => $body,
            'timeout'     => '5',
            'redirection' => '5',
            'httpversion' => '1.0',
            'blocking'    => true,
            'headers'     => array(),
            'cookies'     => array(),
        );

        $response = wp_remote_post($this->api_url, $args);