uri push

result:
{
"remain":4999998,
"success":2,
"not_same_site":[],
"not_valid":[]
}

@param  mixed $urls array|string
@param  array $site_options ['site' => ..., 'token' => ...]

@return string json string
428149
static public function push($urls, $site_options=null)
    {
        /*
        $urls = array(
            'http://www.example.com/1.html',
            'http://www.example.com/2.html',
        );
        */
        if (is_string($urls)) {
            $urls = str_replace(["\r\n", '<br>'], "\n", $urls);
        } else {
            $urls = implode("\n", $urls);
        }
        
        $api = sprintf('https://data.zz.baidu.com/urls?site=%s&token=%s', $site_options['site'], $site_options['token']);
        
        $ch = curl_init();
        $options =  array(
            CURLOPT_URL     => $api,
            CURLOPT_POST    => true,
            CURLOPT_RETURNTRANSFER  => true,
            CURLOPT_POSTFIELDS      => $urls,
            CURLOPT_HTTPHEADER      => array('Content-Type: text/plain'),
        );
        curl_setopt_array($ch, $options);
        $result = curl_exec($ch);
        echo $result;
    }
1216427
public function URLToDOCX($url, GrabzItDOCXOptions $options = null)
	{
		if ($options == null)
		{
			$options = new GrabzItDOCXOptions();
		}		

		$this->request = new GrabzItRequest($this->getRootUrl(false) . GrabzItClient::TakeDOCX, false, $options, $url);
	}
970958
public static function getRootPageIdsFromSites(array $sites): array
    {
        $rootPageIds = [];
        foreach ($sites as $site) {
            $rootPageIds[] = (int)$site->getRootPageId();
        }

        return $rootPageIds;
    }
846552
public static function getUri($site, $url) {
		$site = $site ?: self::getHost($url);

		$site = self::wwwLess($site);
		$Idna = new IdnaConvert();
		// конвертим сайт в idna
		$idna = $Idna->encode($site);
		$page = self::httpLess($url);
		$page = str_replace(array("www.$site", $site, $idna, "www.$idna"), '', $page);

		return (empty($page)) ? '/' : $page;
	}
1120521
private function validateUrl($url)
    {
        if ($url === false)
            return $url;
        $resolver = new OptionsResolver();
        $resolver->setRequired([
            'url',
        ]);
        $resolver->setDefaults([
            'url_options' => [],
            'url_type' => 'json',
        ]);
        $resolver->setAllowedTypes('url_options', ['array']);
        $resolver->setAllowedTypes('url', ['string']);
        $resolver->setAllowedTypes('url_type', ['string']);
        $resolver->setAllowedValues('url_type', ['redirect', 'json']);
        $url = $resolver->resolve($url);
        return $url;
    }
178680
public function toUrl($url, $parameters)
	{
		foreach ($parameters as $key => $value)
		{
			if (\is_array($value))
			{
				foreach ($value as $k => $v)
				{
					if (strpos($url, '?') === false)
					{
						$url .= '?' . $key . '=' . $v;
					}
					else
					{
						$url .= '&' . $key . '=' . $v;
					}
				}
			}
			else
			{
				if (strpos($value, ' ') !== false)
				{
					$value = $this->safeEncode($value);
				}

				if (strpos($url, '?') === false)
				{
					$url .= '?' . $key . '=' . $value;
				}
				else
				{
					$url .= '&' . $key . '=' . $value;
				}
			}
		}

		return $url;
	}
846732
public function httpRaw($url, $postOptions, array $options = [])
    {
        Yii::info([
            'url' => $url,
            'postOptions' => $postOptions,
            'options' => $options
        ], __METHOD__);
        return $this->parseHttpRequest(function($url, $postOptions) {
            return $this->http($url, [
                CURLOPT_POST => true,
                CURLOPT_POSTFIELDS => is_array($postOptions) ? json_encode($postOptions, JSON_UNESCAPED_UNICODE) : $postOptions
            ]);
        }, $this->httpBuildQuery($url, $options), $postOptions);
    }
1235115
private function _prepare_urls($urls) {

        // if $urls is *one* associative array containing one of "url", "options" and "data" entries
        if (is_array($urls) && !empty(array_intersect(array('url', 'options', 'data'), array_keys($urls)))) {

            // since "url" is mandatory, stop if not present
            if (!isset($urls['url'])) trigger_error('<strong>url</strong> key is missing from argument', E_USER_ERROR);

            // return as an array of arrays
            return array($urls);

        // if $urls is an array
        } elseif (is_array($urls)) {

            $result = array();

            // iterate over the entries in the array
            foreach ($urls as $key => $values) {

                // if key is numeric, as in
                // array('http://address.com')
                // array(array(
                //      'url'       =>  'http://address.com',
                //      'options'   =>  array(...)
                // ))
                if (is_numeric($key)) {

                    // if $values is an associative array containing one of "url", "options" and "data" entries, like
                    // array(
                    //      'url'       =>  'http://address.com',
                    //      'options'   =>  array(...)
                    // )
                    if (is_array($values) && !empty(array_intersect(array('url', 'options', 'data'), array_keys($values)))) {

                        // since "url" is mandatory, stop if not present
                        if (!isset($values['url'])) trigger_error('<strong>url</strong> key is missing from argument', E_USER_ERROR);

                        // keep everything as it is
                        $result[] = $values;

                    // if $values is not an array or not an associative array containing one of "url", "options" and "data" entries, like
                    // 'http://address.com'
                    } else {

                        // it has to be the URL
                        $result[] = array('url' => $values);

                    }

                // if key is not numeric, as in
                // 'http://address.com' => array(...)
                } else {

                    // the value has to be the "data"
                    $result[] = array('url' => $key, 'data' => $values);

                }

            }

            // update the values
            $urls = $result;

        // if $urls is not an array, as in
        // 'http://address.com'
        } else {

            // it has to be the URL, and make it an array of arrays
            $urls = array(array('url' => $urls));

        }

        // walk recursively through the array
        array_walk_recursive($urls, function(&$value) {

            // if we have to upload a file
            if (strpos($value, '@') === 0)

                // if PHP version is 5.5+
                if (version_compare(PHP_VERSION, '5.5') >= 0) {

                    // remove the @ from the name
                    $file = substr($value, 1);

                    // use CURLFile to prepare the file
                    $value = new CURLFile($file);

                }

        });

        // return the normalized array
        return $urls;

    }
485148
protected function _getCssOutput(array $options, $url)
    {
        if ($options['rel'] === 'import') {
            return $this->formatTemplate('style', [
                'attrs'   => $this->templater()->formatAttributes($options, ['rel', 'block', 'weight', 'alias']),
                'content' => '@import url(' . $url . ');',
            ]);
        }

        return $this->formatTemplate('css', [
            'rel'   => $options['rel'],
            'url'   => $url,
            'attrs' => $this->templater()->formatAttributes($options, ['rel', 'block', 'weight', 'alias']),
        ]);
    }
99130
public function url(array $options) {
        if (empty($this->elementData) || filter_var($this->elementData, FILTER_VALIDATE_URL)) {
            $this->elementData = filter_var($this->elementData, FILTER_SANITIZE_URL);
            return true;
        }

        $this->addError($this->checkMessage('Value is not a valid url', $options));
        return false;
    }
234773
public function getAvailableSites($stopOnInvalidSite = false)
    {
        $sites = [];
        $cacheId = 'SiteRepository' . '_' . 'getAvailableSites';

        $methodResult = $this->runtimeCache->get($cacheId);
        if (!empty($methodResult)) {
            return $methodResult;
        }

        $servers = $this->getSolrServersFromRegistry();
        foreach ($servers as $server) {
            if (isset($sites[$server['rootPageUid']])) {
                //get each site only once
                continue;
            }

            try {
                $sites[$server['rootPageUid']] = $this->buildSite($server['rootPageUid']);
            } catch (\InvalidArgumentException $e) {
                if ($stopOnInvalidSite) {
                    throw $e;
                }
            }
        }

        $methodResult = $sites;
        $this->runtimeCache->set($cacheId, $methodResult);

        return $methodResult;
    }
1282602
public function put($url, $params = array(), $options = array()) {
        $file = '';
        $fp = false;
        if (isset($params['file'])) {
            $file = $params['file'];
            if (is_file($file)) {
                $fp   = fopen($file, 'r');
                $size = filesize($file);
                $options['CURLOPT_PUT']        = 1;
                $options['CURLOPT_INFILESIZE'] = $size;
                $options['CURLOPT_INFILE']     = $fp;
            } else {
                return null;
            }
            if (!isset($this->options['CURLOPT_USERPWD'])) {
                $this->setopt(array('CURLOPT_USERPWD' => 'anonymous: noreply@moodle.org'));
            }
        } else {
            $options['CURLOPT_CUSTOMREQUEST'] = 'PUT';
            $options['CURLOPT_POSTFIELDS'] = $params;
        }

        $ret = $this->request($url, $options);
        if ($fp !== false) {
            fclose($fp);
        }
        return $ret;
    }
647427
public function forceSiteUrl(&$options, $site)
    {
        if (!$site instanceof Site) {
            $site = $this->storage->findOne($site);
        }

        if ($GLOBALS['is_https']) {
            $options['https'] = !$site->isHttpsAllowed();
        } else if (variable_get('https', false)) {
            $options['https'] = !$site->isHttpAllowed();
        } else {
            // Sorry, HTTPS is disabled at the Drupal level, note that it is not
            // mandatory to this because url() will do the check by itself, but
            // because there is in here one code path in which we are going to
            // manually set the base URL, we need to compute that by ourselves.
            $options['https'] = false;
        }

        // Warning, this is a INTERNAL url() function behavior, so we have
        // to reproduce a few other behaviours to go along with it, such as
        // manual http vs https handling. Please see the variable_get('https')
        // documentation above.
        $options['base_url'] = ($options['https'] ? 'https://' : 'http://') . $site->getHostname();
        $options['absolute'] = true;
    }
473251
public function generate($location, array $options = [])
    {
        $uri = $this->fetchUrl($location, $options);
        $this->decorate($uri);
        return $uri;
    }
973562
public static function token($params = null, $opts = null)
    {
        $base = ($opts && array_key_exists('connect_base', $opts)) ? $opts['connect_base'] : Stripe::$connectBase;
        $requestor = new ApiRequestor(null, $base);
        list($response, $apiKey) = $requestor->request(
            'post',
            '/oauth/token',
            $params,
            null
        );
        return Util\Util::convertToStripeObject($response->json, $opts);
    }
1072409
protected function callHttp(array $options)
    {
        $options += [
            'method' => 'post',
            'dataType' => 'json',
            'throwException' => false,
        ];
        $options['url'] = $this->baseUrl . $options['url'];
        $options['data'] = json_encode($options['data'], JSON_UNESCAPED_UNICODE);

        $http = $this->http($options);

        return $this->parseResponse($http, $options);
    }
418385
public function post($url, $xml, $options = array())
    {
        $rst = $this->getRequest()->post($url, array(), $options, $xml);
        return $rst;
    }