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


PHP HttpResponse::setData方法代码示例

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


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

示例1: render

 /**
  * @param string
  * @param array
  * @return HttpRequest
  */
 public function render($template, $context)
 {
     $render = $this->get('render');
     $response = new HttpResponse();
     $response->setData($render->render($template, $context));
     return $response;
 }
开发者ID:Everus,项目名称:wbf.test,代码行数:12,代码来源:controller.php

示例2: handleRead

 protected function handleRead($read_sock)
 {
     //	read up to 10000 bytes
     // $data = '';
     // while(true)
     // {
     // 	echo "getting line\n";
     // 	socket_set_nonblock($read_sock);
     // 	$line = socket_read($read_sock, 1024, PHP_BINARY_READ);
     // 	echo "type = " . gettype($line) . "\n";
     // 	echo "len = " . strlen($line) . "\n";
     // 	echo "value = $line\n";
     //
     // 	$err = socket_last_error($read_sock);
     // 	if($err)
     // 		echo "error = " . socket_strerror($err) . "\n";
     // 	else
     // 		echo "no error\n";
     //
     // 	if(strlen($line) == 0)
     // 		break;
     // 	$data .= $line;
     // }
     $data = socket_read($read_sock, 1024, PHP_BINARY_READ);
     // if(strlen($data) == 5)
     // 	for($i = 0; $i < strlen($data); $i++)
     // 		echo "the char is = " . ord($data[$i]) . "\n";
     echo "start dumping raw data\n";
     var_dump($data);
     echo "done dumping raw data\n";
     // check if the client is disconnected
     // if ($data === false)
     if (!$data) {
         // remove client for $this->clients array
         $key = array_search($read_sock, $this->clients);
         unset($this->clients[$key]);
         echo "client disconnected.\n";
         // continue to the next client to read from, if any
         return;
     }
     echo "recieving request\n";
     // check if there is any data after trimming off the spaces
     if (!empty($data)) {
         echo "printing raw request content\n";
         echo $data . "\n";
         //
         $message = new HttpMessage($data);
         echo "printing out message object\n";
         print_r($message);
         echo $message->getType() . "\n";
         echo $message->getRequestMethod() . "\n";
         echo $message->getRequestUrl() . "\n";
         HttpResponse::setData("<html><body>asdf</body></html>");
         print_r(HttpResponse::getRequestHeaders());
         // HttpResponse::send();
         // echo "printing the data\n";
         // echo HttpResponse::getData();
     } else {
         echo "received empty request\n";
         sleep(10);
     }
     echo "done receiving request\n\n\n\n";
 }
开发者ID:laiello,项目名称:zoop,代码行数:63,代码来源:HttpServer.php

示例3: phpSerial

    $serial = new phpSerial();
    $serial->deviceSet("/dev/ttyACM0");
    $serial->confBaudRate(9600);
    $serial->confParity("none");
    $serial->confCharacterLength(8);
    $serial->confStopBits(1);
    $serial->deviceOpen();
    // arduino requires a 2 second delay in order to receive the message
    sleep(2);
    // Si c'est une request hi on allumera la led
    $data = $_GET["hi"];
    $serial->sendMessage($data);
    $read[$cnt] = $serial->readPort();
    while (substr($read[$cnt], -1, 1) != "a") {
        $cnt++;
        $read[$cnt] = $serial->readPort();
    }
    for ($i = 1; $i < $cnt + 1; $i++) {
        $rcv = $rcv . $read[$i];
    }
    $rcv = rtrim($rcv, "a");
    // Si c'est une request temperature on renvoiera la température (voir index.php pour le retour de valeur)
    // afficher température sur le bobox
    // Si c'est une request heure on affiche l'heure sur le bobox (pas besoin sur téléphone
    // Variation de lumière -> quelqun dans la piece ! notification téléphone ? a voir...
    HttpResponse::setCache(true);
    HttpResponse::setContentType('text/plain');
    HttpResponse::setData($rcv);
    HttpResponse::send();
    $serial->deviceClose();
}
开发者ID:ridergoster,项目名称:Boxobox,代码行数:31,代码来源:android.php

示例4: actionLongPoller

 public function actionLongPoller()
 {
     $model = new LongPoller();
     //$request = http_get_request_body();
     $request = json_encode(array("deviceID" => "90:C1:15:BC:97:4F", "orderNo" => "1"));
     $model->decodeStatusRequest($request);
     $model->checkStatus();
     $responseMsg = $model->generateResponse();
     HttpResponse::status(200);
     HttpResponse::setContentType('application/json');
     HttpResponse::setData($responseMsg);
     HttpResponse::send();
 }
开发者ID:nsawant942,项目名称:Canteen-Management-Software-System--Witwatersrand,代码行数:13,代码来源:MobileController.php

示例5: json_encode

<?php

require_once 'HTTP/Request2/Response.php';
//echo "Hello there you are now connected to the canteen web server <br />";
/*HttpResponse::status(200);
HttpResponse::setContentType('json');
//HttpResponse::setHeader('From', 'Lymber');
HttpResponse::setData($_POST);
HttpResponse::send();*/
$connection = Yii::app()->db;
$sql_select = 'SELECT *   FROM menu';
$command = $connection->createCommand($sql_select);
$menuData = $command->query();
$row = $menuData->readAll();
$json_string = json_encode(array("updated" => "false", 'menu:' => $row));
$headers = http_get_request_headers();
$result = http_get_request_body();
$decodeResult = json_decode($result);
HttpResponse::status(200);
HttpResponse::setContentType('application/json');
//HttpResponse::setHeader('From', 'Lymber');
HttpResponse::setData($json_string);
HttpResponse::send();
flush();
开发者ID:nsawant942,项目名称:Canteen-Management-Software-System--Witwatersrand,代码行数:24,代码来源:mobileTest.php


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