Kong / unirest-php

Unirest in PHP: Simplified, lightweight HTTP client library.
http://unirest.io/php
MIT License
1.28k stars 328 forks source link

send function do no accept array ... on line 408 #123

Open coscho opened 7 years ago

coscho commented 7 years ago

public static function send($method, $url, $body = null, $headers = array(), $username = null, $password = null) { self::$handle = curl_init();

    if ($method !== Method::GET) {
        if ($method === Method::POST) {
            curl_setopt(self::$handle, CURLOPT_POST, true);
        } else {
            if ($method === Method::HEAD) {
                curl_setopt(self::$handle, CURLOPT_NOBODY, true);
            }
            curl_setopt(self::$handle, CURLOPT_CUSTOMREQUEST, $method);
        }
        // to accept array http_build_query must me used
        curl_setopt(self::$handle, CURLOPT_POSTFIELDS, http_build_query($body));
    } elseif (is_array($body)) {
        if (strpos($url, '?') !== false) {
            $url .= '&';
        } else {
            $url .= '?';
        }

        $url .= urldecode(http_build_query(self::buildHTTPCurlQuery($body)));
    }
rayliverified commented 6 years ago

This is a pretty critical issue.