@param string $url
@param string|array $postFields

@throws InvalidArgumentException
@return string|false
770821
public function multipart( $url, $postFields ) {
		$this->assertString( 'url', $url );

		if ( !isset( $this->conn ) ) {
			$this->connect();
		}

		$headers = array(
			'Content-Type' => 'multipart/form-data'
		);

		curl_setopt( $this->conn, CURLOPT_TIMEOUT, 500 );

		return $this->post( $url, $postFields, $headers );
	}
1168696
static public function submit( $url )
	{
		if( $url instanceof ADT_URL )
			$url	= (string) $url;
		if( !is_string( $url ) )
			throw new InvalidArgumentException( 'URL must be string or instance of ADT_URL' );
		try
		{
			Net_Reader::readUrl( self::$baseUrl.urlencode( $url ) );
		}
		catch( Exception $e )
		{
			self::$lastError	= $e->getMessage();
			return FALSE;
		}
		return TRUE;
	}
436143
protected function curl_access_token($url, $postFields = NULL)
    {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_TIMEOUT, 3);
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_FAILONERROR, FALSE);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
        //https 请求
        if (strlen($url) > 5 && strtolower(substr($url, 0, 5)) == 'https') {
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
        }

        if (is_array($postFields) && 0 < count($postFields)) {
            $postBodyString = '';
            $postMultipart = FALSE;
            foreach ($postFields as $k => $v) {
                if ('@' != substr($v, 0, 1)) //判断是不是文件上传
                {
                    $postBodyString .= "$k=" . urlencode($v) . "&";
                } else {
                    //文件上传用multipart/form-data，否则用www-form-urlencoded
                    $postMultipart = TRUE;
                }
            }
            $postFields = trim($postBodyString, '&');
            unset($k, $v);
            curl_setopt($ch, CURLOPT_POST, TRUE);
            if ($postMultipart) {
                curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
            } else {
                curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
            }
        }

        $reponse = curl_exec($ch);
        curl_close($ch);
        return $reponse;
    }
759744
public function lookForBrokenLinks($postId = null, $url = null)
    {
        \BrokenLinkDetector\App::checkInstall();
        $foundUrls = array();

        if ($url) {
            $url = "REGEXP ('.*(href=\"{$url}\").*')";
        } else {
            $url = "RLIKE ('href=*')";
        }

        global $wpdb;
        $sql = "
            SELECT ID, post_content
            FROM $wpdb->posts
            WHERE
                post_content {$url}
                AND post_type NOT IN ('attachment', 'revision', 'acf', 'acf-field', 'acf-field-group')
                AND post_status IN ('publish', 'private', 'password')
        ";

        if (is_numeric($postId)) {
            $sql .= " AND ID = $postId";
        }

        $posts = $wpdb->get_results($sql);

        if(is_array($posts) && !empty($posts)) {
            foreach ($posts as $post) {
                preg_match_all('/<a[^>]+href=([\'"])(http|https)(.+?)\1[^>]*>/i', $post->post_content, $m);

                if (!isset($m[3]) || count($m[3]) > 0) {
                    foreach ($m[3] as $key => $url) {
                        $url = $m[2][$key] . $url;

                        // Replace whitespaces in url
                        if (preg_match('/\s/', $url)) {
                            $newUrl = preg_replace('/ /', '%20', $url);
                            $wpdb->query(
                                $wpdb->prepare(
                                    "UPDATE $wpdb->posts
                                        SET post_content = REPLACE(post_content, %s, %s)
                                        WHERE post_content LIKE %s
                                        AND ID = %d",
                                    $url,
                                    $newUrl,
                                    '%' . $wpdb->esc_like($url) . '%',
                                    $post->ID
                                )
                            );
                            $url = $newUrl;
                        }

                        if ($postId !== 'internal' && !$this->isBroken($url)) {
                            continue;
                        }

                        $foundUrls[] = array(
                            'post_id' => $post->ID,
                            'url' => $url
                        );
                    }
                }
            }
        }

        $this->saveBrokenLinks($foundUrls, $postId);
    }
1187826
protected function postRequest($url, $parameters = [])
    {
        if (!empty($parameters)) {
            $this->parameters->addPost($parameters);
        }

        return $this->request($url);
    }
751788
public function getJsonAsArray($url, $useragent = 'PHP/cURL', $timeout = 5, $customHeaders = false, $postArray = array())
    {
        $result = $this->BackyardHttp->getData($url, $useragent, $timeout, $customHeaders, $postArray);
        $json = $result['message_body'];
        if (!$json) {
            $this->BackyardError->log(2, "No content on {$url}");
            return false;
        }
        $jsonArray = $this->jsonCleanDecode($json, true);
        if (!$jsonArray) {
            $this->BackyardError->log(2, "Trouble with decoding JSON from {$url}");
            return false;
        }
        return $jsonArray;
    }
309937
public static function isHttp(string $url)
    {
        $url = UrlHelper::validateUrl($url);

        $parsedUrl = parse_url($url);
        if ($parsedUrl === false) {
            throw new InvalidArgumentException("The provided url is not valid: $url");
        }

        return $parsedUrl["scheme"] === UrlHelper::HTTP_SCHEME;
    }
1174342
public static function findOrThrow($param, $field = '*', $parameters = array()) {
        $model = static::find($param, $field, $parameters);
        if (empty($model)) {
            throw new \InvalidArgumentException($param);
        }
        return $model;
    }
275716
protected function _updateObject( $post_id, $fields ) {
		$fields['ID'] = $post_id;
		$updated = wp_update_post( $fields );
		if ( $updated && ! is_wp_error( $updated ) ) {
			$this->_debug( 'Updated post ' . $post_id );
		} elseif ( is_wp_error( $updated ) ) {
			$this->_debug(
				'Update failed for post %d with message [%s] %s',
				$post_id,
				$updated->get_error_code(),
				$updated->get_error_message()
			);
		} else {
			$this->_debug( 'Update failed for post ' . $post_id );
		}

		return $updated;
	}
1180349
protected function sendFile($uri, array $postFields)
    {
        $curlResource = $this->initCurlUpload();

        $curlOptions  = $this->getOptionsCurlUpload($uri, $postFields);

        $curlResource = $this->setOptionsCurlUpload($curlResource, $curlOptions);

        return $this->execCurlUpload($curlResource);
    }
854241
public function url($url)
    {
        if (filter_var($url, FILTER_VALIDATE_URL) !== false) {
            return $url;
        }

        if (is_string($url)) {
            return $this->parseStringUrl($url);
        }

        if (is_array($url)) {
            return $this->make(new UrlSettings($url));
        }

        if ($url instanceof UrlSettings) {
            return $this->make($url);
        }

        throw new \InvalidArgumentException('Settings is not a supported type');
    }
1338516
public static function GetQueryStringFromKeyVals(string $url, array $keyVals)
    {
        if ($url == NULL) {
            throw new \InvalidArgumentException('url');
        }

        if ($keyVals == NULL) {
            throw new \InvalidArgumentException('keyVals');
        }

        $anchorIndex = strpos($url, '#');
        $resultUri = $url;
        $anchorText = "";
        if ($anchorIndex !== FALSE) {
            $anchorText = substr($url, $anchorIndex);
            $resultUri = substr($url, 0, $anchorIndex);
        }

        $queryIndex = strpos($resultUri, '?');
        $hasQuery = $queryIndex !== FALSE;

        $sb = '';
        $sb .= $resultUri;
        foreach ($keyVals as $keyKey => $keyVal) {
            $sb .= $hasQuery ? '&' : '?';
            $sb .= urlencode($keyKey);
            $sb .= '=';
            $sb .= urlencode($keyVal);
            $hasQuery = TRUE;
        }

        $sb .= $anchorText;

        return $sb;
    }
596424
public function setPostFields($value) {
        if (is_array($value)) {
            return $this->setOption(CURLOPT_POSTFIELDS, http_build_query($value));
        } else {
            return $this->setOption(CURLOPT_POSTFIELDS, $value);
        }
    }
111370
function http($url, $method, $postfields = NULL, $headers = array()) {
        $this->http_info = array();
        $ci = curl_init();
        /* Curl settings */
        curl_setopt($ci, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
        curl_setopt($ci, CURLOPT_USERAGENT, $this->useragent);
        curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, $this->connecttimeout);
        curl_setopt($ci, CURLOPT_TIMEOUT, $this->timeout);
        curl_setopt($ci, CURLOPT_RETURNTRANSFER, TRUE);
        curl_setopt($ci, CURLOPT_ENCODING, "");
        curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, $this->ssl_verifypeer);
        if (version_compare(phpversion(), '5.4.0', '<')) {
            curl_setopt($ci, CURLOPT_SSL_VERIFYHOST, 1);
        } else {
            curl_setopt($ci, CURLOPT_SSL_VERIFYHOST, 2);
        }
        curl_setopt($ci, CURLOPT_HEADERFUNCTION, array($this, 'getHeader'));
        curl_setopt($ci, CURLOPT_HEADER, FALSE);

        switch ($method) {
            case 'POST':
                curl_setopt($ci, CURLOPT_POST, TRUE);
                if (!empty($postfields)) {
                    curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields);
                    $this->postdata = $postfields;
                }
                break;
            case 'DELETE':
                curl_setopt($ci, CURLOPT_CUSTOMREQUEST, 'DELETE');
                if (!empty($postfields)) {
                    $url = "{$url}?{$postfields}";
                }
        }

        curl_setopt($ci, CURLOPT_URL, $url );
        curl_setopt($ci, CURLOPT_HTTPHEADER, $headers );
        curl_setopt($ci, CURLINFO_HEADER_OUT, TRUE );

        $response = curl_exec($ci);
        $this->http_code = curl_getinfo($ci, CURLINFO_HTTP_CODE);
        $this->http_info = array_merge($this->http_info, curl_getinfo($ci));
        $this->url = $url;

        if ($this->debug) {
            echo "=====post data======\r\n";
            var_dump($postfields);

            echo "=====headers======\r\n";
            print_r($headers);

            echo '=====request info====='."\r\n";
            print_r( curl_getinfo($ci) );

            echo '=====response====='."\r\n";
            print_r( $response );
        }
        curl_close ($ci);
        return $response;
    }
275431
public function validateUrl($url)
    {
        if ('' === $url) {
            return $this;
        }

        if (!is_string($url) || strlen($url) > 2000) {
            throw new InvalidArgumentException(
                'URL must be a string of at most 2,000 characters',
                400
            );
        }

        return $this;
    }
339682
private function executeQuery(string $url): AddressCollection
    {
        $content = $this->getUrlContents($url);
        $json = json_decode($content, true);

        if (!is_array($json) || !count($json)) {
            throw InvalidServerResponse::create($url);
        }

        if (!array_key_exists('geoplugin_status', $json) || (200 !== $json['geoplugin_status'] && 206 !== $json['geoplugin_status'])) {
            return new AddressCollection([]);
        }

        // Return empty collection if address was not found
        if ('' === $json['geoplugin_regionName']
        && '' === $json['geoplugin_regionCode']
        && '' === $json['geoplugin_city']
        && '' === $json['geoplugin_countryName']
        && '' === $json['geoplugin_countryCode']
        && '0' === $json['geoplugin_latitude']
        && '0' === $json['geoplugin_longitude']) {
            return new AddressCollection([]);
        }

        $data = array_filter($json);

        $adminLevels = [];

        $region = \igorw\get_in($data, ['geoplugin_regionName']);
        $regionCode = \igorw\get_in($data, ['geoplugin_regionCode']);

        if (null !== $region || null !== $regionCode) {
            $adminLevels[] = ['name' => $region, 'code' => $regionCode, 'level' => 1];
        }

        $results = [];
        $results[] = Address::createFromArray([
            'providedBy' => $this->getName(),
            'locality' => isset($data['geoplugin_city']) ? $data['geoplugin_city'] : null,
            'country' => isset($data['geoplugin_countryName']) ? $data['geoplugin_countryName'] : null,
            'countryCode' => isset($data['geoplugin_countryCode']) ? $data['geoplugin_countryCode'] : null,
            'adminLevels' => $adminLevels,
            'latitude' => isset($data['geoplugin_latitude']) ? $data['geoplugin_latitude'] : null,
            'longitude' => isset($data['geoplugin_longitude']) ? $data['geoplugin_longitude'] : null,
        ]);

        return new AddressCollection($results);
    }
763347
public function options($url, $fields = null, callable $callback = null)
    {
        $this->send($url, self::OPTIONS, $fields, $callback);
    }