当前位置: 首页>>代码示例>>PHP>>正文


PHP Uri::setUserInfo方法代码示例

本文整理汇总了PHP中Zend\Uri\Uri::setUserInfo方法的典型用法代码示例。如果您正苦于以下问题:PHP Uri::setUserInfo方法的具体用法?PHP Uri::setUserInfo怎么用?PHP Uri::setUserInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\Uri\Uri的用法示例。


在下文中一共展示了Uri::setUserInfo方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: request

 /**
  * @param                    $method
  * @param                    $uri
  * @param array              $options
  * @param null|bool|\Closure $successCallback
  * @param null|bool|\Closure $failCallback
  *
  * @return bool|null|\StdClass
  * @throws Exception
  */
 public function request($method, $uri, $options = [], $successCallback = null, $failCallback = null)
 {
     if (!$successCallback && !$failCallback) {
         $json = null;
         // If there's no callbacks defined we assume this is a RESTful request
         Logger::getInstance()->debug($method . ' ' . $uri . ' ' . json_encode($options));
         $options = array_merge($this->defaultOptions, $options);
         $guzzle = new GuzzleHttp\Client(['base_uri' => self::BASE_URL_REST]);
         $res = $guzzle->request($method, $uri, $options);
         if ($res->getHeader('content-type')[0] == 'application/json') {
             $contents = $res->getBody()->getContents();
             Logger::getInstance()->debug($contents);
             $json = json_decode($contents);
         } else {
             throw new Exception("Server did not send JSON. Response was \"{$res->getBody()->getContents()}\"");
         }
         return $json;
     } else {
         // Use the STREAM API end point
         $Uri = new Uri(self::BASE_URL_STREAM);
         $Uri->setUserInfo($this->defaultOptions['auth'][0] . ':' . $this->defaultOptions['auth'][1]);
         $Uri->setPath($uri);
         if (isset($options['query'])) {
             $Uri->setQuery($options['query']);
         }
         $WSClient = new WebSocket\Client($Uri);
         Logger::getInstance()->debug($Uri);
         if (!$successCallback instanceof \Closure) {
             $successCallback = function ($response) {
                 $info = json_decode($response);
                 if (property_exists($info, 'output')) {
                     Logger::getInstance()->info(json_decode($response)->output);
                 } elseif ($info->type == 'error') {
                     // output error info
                     Logger::getInstance()->info($info->message);
                 }
             };
         }
         if (!$failCallback instanceof \Closure) {
             $failCallback = function (\Exception $exception) {
                 Logger::getInstance()->info($exception->getMessage());
             };
         }
         try {
             while ($response = $WSClient->receive()) {
                 $successCallback($response);
             }
         } catch (\Exception $e) {
             $failCallback($e);
         }
         return true;
     }
 }
开发者ID:allansun,项目名称:docker-cloud-php-api,代码行数:63,代码来源:Client.php

示例2: clearUri

 /**
  * Get clear uri.
  *
  * @static
  *
  * @param \Zend\Uri\Uri $uri
  *
  * @return boolean|\Zend\Uri\Uri False if uri is not auhorized
  */
 public static function clearUri(Uri $uri)
 {
     if ($uri->getScheme() !== 'http') {
         return false;
     }
     $uri->setHost('www.vimeo.com');
     // clear
     $uri->setPort(0);
     $uri->setUserInfo('');
     $uri->setQuery('');
     $uri->setFragment('');
     return $uri;
 }
开发者ID:pokap,项目名称:media,代码行数:22,代码来源:Vimeo.php

示例3: clearUri

 /**
  * Get clear uri.
  *
  * @static
  *
  * @param \Zend\Uri\Uri $uri
  *
  * @return boolean|\Zend\Uri\Uri False if uri is not auhorized
  */
 public static function clearUri(Uri $uri)
 {
     if ($uri->getScheme() !== 'http') {
         return false;
     }
     $query = $uri->getQueryAsArray();
     if (empty($query['v'])) {
         return false;
     }
     $uri->setQuery(array('v' => $query['v']));
     $uri->setHost('www.youtube.com');
     $uri->setPath('/watch');
     // clear
     $uri->setPort(0);
     $uri->setUserInfo('');
     $uri->setFragment('');
     return $uri;
 }
开发者ID:pokap,项目名称:media,代码行数:27,代码来源:Youtube.php

示例4: invalidRelativeUriObjectProvider

 /**
  * Data provider for invalid relative URI objects
  *
  * @return array
  */
 public function invalidRelativeUriObjectProvider()
 {
     // Empty URI is not valid
     $obj1 = new Uri();
     // Path cannot begin with '//'
     $obj2 = new Uri();
     $obj2->setPath('//path');
     // A object with port
     $obj3 = new Uri();
     $obj3->setPort(123);
     // A object with userInfo
     $obj4 = new Uri();
     $obj4->setUserInfo('shahar:password');
     // A object with scheme
     $obj5 = new Uri();
     $obj5->setScheme('https');
     // A object with host
     $obj6 = new Uri();
     $obj6->setHost('example.com');
     return array(array($obj1), array($obj2), array($obj3), array($obj4), array($obj5), array($obj6));
 }
开发者ID:navassouza,项目名称:zf2,代码行数:26,代码来源:UriTest.php

示例5: invalidUriObjectProvider

    /**
     * Data provider for invalid URI objects
     *
     * @return array
     */
    static public function invalidUriObjectProvider()
    {
        // Empty URI is not valid
        $obj1 = new Uri;

        // Path cannot begin with '//' if there is no authority part
        $obj2 = new Uri;
        $obj2->setPath('//path');

        // A port-only URI with no host
        $obj3 = new Uri;
        $obj3->setPort(123);

        // A userinfo-only URI with no host
        $obj4 = new Uri;
        $obj4->setUserInfo('shahar:password');

        return array(
            array($obj1),
            array($obj2),
            array($obj3),
            array($obj4)
        );
    }
开发者ID:ruflin,项目名称:zf2,代码行数:29,代码来源:UriTest.php

示例6: clearUri

 /**
  * Get clear uri.
  *
  * @static
  *
  * @param \Zend\Uri\Uri $uri
  *
  * @return boolean|\Zend\Uri\Uri False if uri is not auhorized
  */
 public static function clearUri(Uri $uri)
 {
     if ($uri->getScheme() !== 'http') {
         return false;
     }
     $paths = explode('/', $uri->getPath());
     $pathsCount = count($paths);
     if ($pathsCount < 2) {
         return false;
     }
     $type = $paths[$pathsCount - 2];
     if (!in_array($type, self::$typesAuthorized)) {
         return false;
     }
     $uri->setHost('www.deezer.com');
     // clear
     $uri->setPort(0);
     $uri->setUserInfo('');
     $uri->setQuery('');
     $uri->setFragment('');
     return $uri;
 }
开发者ID:pokap,项目名称:media,代码行数:31,代码来源:Deezer.php

示例7: setUserInfo

 /**
  * Set the URI User-info part (usually user:password)
  *
  * @param  string $userInfo
  * @return \Zend\Uri\Uri
  * @throws Exception\InvalidUriPartException If the schema definition
  * does not have this part
  */
 public function setUserInfo($userInfo)
 {
     $this->uri->setUserInfo($userInfo);
     return $this;
 }
开发者ID:sunnyct,项目名称:silexcmf-core,代码行数:13,代码来源:Uri.php


注:本文中的Zend\Uri\Uri::setUserInfo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。