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


PHP Client::send方法代码示例

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


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

示例1: sendRequest

 /**
  * @param RequestInterface $request
  */
 private function sendRequest(RequestInterface $request)
 {
     try {
         $this->lastResponse = $this->httpClient->send($request);
     } catch (ClientException $e) {
         $this->lastResponse = $e->getResponse();
     }
 }
开发者ID:robertlemke,项目名称:php-eventstore-client,代码行数:11,代码来源:EventStore.php

示例2: send

 /**
  * Perform all queued HTTP transfers
  *
  * @return API self
  */
 function send() : API
 {
     $this->__log->debug(__FUNCTION__ . ": start loop");
     while (count($this->__client)) {
         $this->__client->send();
     }
     $this->__log->debug(__FUNCTION__ . ": end loop");
     return $this;
 }
开发者ID:m6w6,项目名称:seekat,代码行数:14,代码来源:API.php

示例3: testSend

 public function testSend()
 {
     $requestMock = new Request('http://www.google.de', Request::METHOD_GET, array('foo' => 'bar'), array(), array(), array(), 'This is a test content');
     $responseMock = new Response('This is a test content', 200);
     $mockAdapter = $this->getMockBuilder('apiTalk\\Adapter\\AdapterInterface')->setMethods(array('send'))->getMock();
     $mockAdapter->expects($this->once())->method('send')->with($requestMock)->will($this->returnValue($responseMock));
     $client = new Client($mockAdapter);
     $response = $client->send($requestMock);
     $this->assertEquals($responseMock, $response, 'Response is not equal!');
 }
开发者ID:ceikermann,项目名称:apitalk,代码行数:10,代码来源:ClientTest.php

示例4: fetchEndpointForUrl

 /**
  * Fetch the provider's endpoint URL for the supplied resource
  *
  * @param string $url The provider's endpoint URL for the supplied resource
  *
  * @return string
  *
  * @throws \InvalidArgumentException If no valid link was found
  */
 protected function fetchEndpointForUrl($url)
 {
     $client = new Client($url);
     $body = $client->send();
     $regexp = str_replace('@formats@', implode('|', $this->supportedFormats), self::LINK_REGEXP);
     if (!preg_match_all($regexp, $body, $matches, PREG_SET_ORDER)) {
         throw new \InvalidArgumentException('No valid oEmbed links found on page.');
     }
     foreach ($matches as $match) {
         if ($match['Format'] === $this->preferredFormat) {
             return $this->extractEndpointFromAttributes($match['Attributes']);
         }
     }
     return $this->extractEndpointFromAttributes($match['Attributes']);
 }
开发者ID:excelwebzone,项目名称:omlex,代码行数:24,代码来源:Discoverer.php

示例5: requestResource

 /**
  * Method returns the response for the requested resource
  * @param  string $pURI
  * @param  array  $pOptions
  * @return mixed
  */
 protected function requestResource($pURL, array $pOptions)
 {
     $options = array_replace_recursive($this->settings['defaults'], $pOptions);
     $format = $options['format'];
     $method = $options['method'];
     $this->setHeaders($options);
     $parameters['headers'] = $this->headers;
     if (isset($options['body'])) {
         $parameters['body'] = $this->formatBody($options);
     }
     $request = $this->client->createRequest($method, $pURL, $parameters);
     try {
         $response = $this->client->send($request);
         $this->event->fire('forrest.response', array($request, $response));
         return $this->responseFormat($response, $format);
     } catch (RequestException $e) {
         $this->assignExceptions($e);
     }
 }
开发者ID:jhoff,项目名称:forrest,代码行数:25,代码来源:Client.php

示例6: wrapXmlrpcServer

 /**
  * Similar to wrapXmlrpcMethod, but will generate a php class that wraps
  * all xmlrpc methods exposed by the remote server as own methods.
  * For more details see wrapXmlrpcMethod.
  *
  * For a slimmer alternative, see the code in demo/client/proxy.php
  *
  * Note that unlike wrapXmlrpcMethod, we always have to generate php code here. It seems that php 7 will have anon classes...
  *
  * @param Client $client the client obj all set to query the desired server
  * @param array $extraOptions list of options for wrapped code. See the ones from wrapXmlrpcMethod plus
  *              - string method_filter      regular expression
  *              - string new_class_name
  *              - string prefix
  *              - bool   simple_client_copy set it to true to avoid copying all properties of $client into the copy made in the new class
  *
  * @return mixed false on error, the name of the created class if all ok or an array with code, class name and comments (if the appropriatevoption is set in extra_options)
  */
 public function wrapXmlrpcServer($client, $extraOptions = array())
 {
     $methodFilter = isset($extraOptions['method_filter']) ? $extraOptions['method_filter'] : '';
     $timeout = isset($extraOptions['timeout']) ? (int) $extraOptions['timeout'] : 0;
     $protocol = isset($extraOptions['protocol']) ? $extraOptions['protocol'] : '';
     $newClassName = isset($extraOptions['new_class_name']) ? $extraOptions['new_class_name'] : '';
     $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool) $extraOptions['encode_php_objs'] : false;
     $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool) $extraOptions['decode_php_objs'] : false;
     $verbatimClientCopy = isset($extraOptions['simple_client_copy']) ? !$extraOptions['simple_client_copy'] : true;
     $buildIt = isset($extraOptions['return_source']) ? !$extraOptions['return_source'] : true;
     $prefix = isset($extraOptions['prefix']) ? $extraOptions['prefix'] : 'xmlrpc';
     $namespace = '\\PhpXmlRpc\\';
     $reqClass = $namespace . 'Request';
     $decoderClass = $namespace . 'Encoder';
     $req = new $reqClass('system.listMethods');
     $response = $client->send($req, $timeout, $protocol);
     if ($response->faultCode()) {
         error_log('XML-RPC: ' . __METHOD__ . ': could not retrieve method list from remote server');
         return false;
     } else {
         $mList = $response->value();
         if ($client->return_type != 'phpvals') {
             $decoder = new $decoderClass();
             $mList = $decoder->decode($mList);
         }
         if (!is_array($mList) || !count($mList)) {
             error_log('XML-RPC: ' . __METHOD__ . ': could not retrieve meaningful method list from remote server');
             return false;
         } else {
             // pick a suitable name for the new function, avoiding collisions
             if ($newClassName != '') {
                 $xmlrpcClassName = $newClassName;
             } else {
                 $xmlrpcClassName = $prefix . '_' . preg_replace(array('/\\./', '/[^a-zA-Z0-9_\\x7f-\\xff]/'), array('_', ''), $client->server) . '_client';
             }
             while ($buildIt && class_exists($xmlrpcClassName)) {
                 $xmlrpcClassName .= 'x';
             }
             /// @todo add function setdebug() to new class, to enable/disable debugging
             $source = "class {$xmlrpcClassName}\n{\npublic \$client;\n\n";
             $source .= "function __construct()\n{\n";
             $source .= $this->buildClientWrapperCode($client, $verbatimClientCopy, $prefix, $namespace);
             $source .= "\$this->client = \$client;\n}\n\n";
             $opts = array('return_source' => true, 'simple_client_copy' => 2, 'timeout' => $timeout, 'protocol' => $protocol, 'encode_php_objs' => $encodePhpObjects, 'decode_php_objs' => $decodePhpObjects, 'prefix' => $prefix);
             /// @todo build phpdoc for class definition, too
             foreach ($mList as $mName) {
                 if ($methodFilter == '' || preg_match($methodFilter, $mName)) {
                     // note: this will fail if server exposes 2 methods called f.e. do.something and do_something
                     $opts['new_function_name'] = preg_replace(array('/\\./', '/[^a-zA-Z0-9_\\x7f-\\xff]/'), array('_', ''), $mName);
                     $methodWrap = $this->wrapXmlrpcMethod($client, $mName, $opts);
                     if ($methodWrap) {
                         if (!$buildIt) {
                             $source .= $methodWrap['docstring'];
                         }
                         $source .= $methodWrap['source'] . "\n";
                     } else {
                         error_log('XML-RPC: ' . __METHOD__ . ': will not create class method to wrap remote method ' . $mName);
                     }
                 }
             }
             $source .= "}\n";
             if ($buildIt) {
                 $allOK = 0;
                 eval($source . '$allOK=1;');
                 if ($allOK) {
                     return $xmlrpcClassName;
                 } else {
                     error_log('XML-RPC: ' . __METHOD__ . ': could not create class ' . $xmlrpcClassName . ' to wrap remote server ' . $client->server);
                     return false;
                 }
             } else {
                 return array('class' => $xmlrpcClassName, 'code' => $source, 'docstring' => '');
             }
         }
     }
 }
开发者ID:TsobuEnterprise,项目名称:phpxmlrpc,代码行数:94,代码来源:Wrapper.php

示例7: die

<?php

include './config.php';
if ($argc < 5) {
    die("Usage: {$argv[0]} [fromHost] [toHost] [port] [message to send.]\n");
}
$fromHost = $argv[1];
$toHost = $argv[2];
$port = $argv[3];
$msg = "";
for ($x = 3; $x < $argc; $x++) {
    if ($x == $argc - 1) {
        $msg .= $argv[$x];
    } else {
        $msg .= $argv[$x] . " ";
    }
}
try {
    $myClient = new Client($fromHost, $toHost, $port);
    echo $myClient->showStatus();
    $myClient->startUp();
    echo $myClient->showStatus();
    $myClient->send($msg);
    $myClient->disconnect();
    echo $myClient->showStatus();
} catch (Exception $e) {
    die("Fatal error: {$e->getMessage()}\n");
}
开发者ID:robertkeizer,项目名称:php-udp,代码行数:28,代码来源:client.php

示例8: post

 public static function post($url, $postData = NULL, $queryString = NULL, array $options = array())
 {
     $c = new Client($url, 'POST', $options);
     $c->setPostData($postData);
     $c->setQueryString($queryString);
     return $c->send();
 }
开发者ID:jejem,项目名称:http-client,代码行数:7,代码来源:Client.php

示例9: testClientSendData

 public function testClientSendData()
 {
     $this->assertTrue(self::$client->send('Hello world'), 'Клиент не может отправить данные');
 }
开发者ID:maestroprog,项目名称:esockets-php,代码行数:4,代码来源:TestEsocketsLinear.php

示例10: onError

    }
    public function onError($client)
    {
        echo "Connect failed" . PHP_EOL;
    }
    public function onClose($client)
    {
        echo "Connection close" . PHP_EOL;
    }
    public function onConnect($client)
    {
        echo "Connection open" . PHP_EOL;
    }
    public function send($data)
    {
        $this->client->send($data);
    }
    public function onReceive(swoole_client $client, $data)
    {
        $data = $this->client->recv();
        print_r($data);
    }
    private function isConnected()
    {
        return $this->client->isConnected();
    }
}
$client = new Client('127.0.0.1', 9501);
$data = json_encode(array('code' => '4001', 'data' => array('id' => 1)));
$client->send($data);
开发者ID:imdaqian,项目名称:Swoole-Framework,代码行数:30,代码来源:client.php


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