티스토리 뷰
<!DOCTYPE.html>
</html>
<html>
<head>
<?php
function Test01(){ // Not completed... File error, 2018.08.20
// Ref. : https://www.phpschool.com/gnuboard4/bbs/board.php?bo_table=tipntech&wr_id=74051
include "HttpClient.class.php";
//https://pat.im/817
echo realpath(__FILE__)."<br>";
echo basename(__FILE__)."<br>";
echo $_SERVER['DOCUMENT_ROOT']."<br>";
$host = "www.bilientsvc.net";
$url = "/Tests/PHPPost_Client01.php";
$post = array('p1'=>'Hello', 'p2'=>'World');
$cookie = array('c1'=>'1234', 'c2'=>'5678');
$Path0 = '/mnt/HDD1/webroot/Tests/';
$Path1 = '/HDD1/webroot/Tests/';
$file = array(
array('name'=>'File1', 'path'=>'/mnt/HDD1/webroot/Tests/TestImage01.jpg')
);
//if(function_exists('HTTPClient')) echo "Yes...";
$client = new HttpClient($host);
if($client == null) echo "client : null";
//if($cookie) $client->setCookies($cookie);
$ret = $client->post($url, $post, $file);
//$ret = $client->post($url, $post);
if($ret == null) echo "ret : null";
$pageContents = "None";
$pageContents = $client->getContent();
echo "<Rst>".$pageContents."</Rst>";
}
function Test02(){ // Failed, 2018.08.20
// Ref : http://php.net/manual/it/httprequest.send.php
//include "./http.php";
$ClientURL ="https://www.bilientsvc.net/Tests/PHPPost_Client01.php";
$r = new HttpRequest($ClientURL, HttpRequest::METH_POST);
$r->setOptions(array('cookies' => array('lang' => 'de')));
$r->addPostFields(array('p1' => 'Hello', 'p2' => 'World'));
//$r->addPostFile('image', 'profile.jpg', 'image/jpeg');
try {
echo $r->send()->getBody();
} catch (HttpException $ex) {
echo $ex;
}
}
function Test03(){ // Failed, 2018.08.20
include "Client.php";
$ClientURL ="http://www.bilientsvc.net/Tests/PHPPost_Client01.php";
$client = new \GuzzleHttp\Client();
$request = $client->get($ClientURL);
$response = $request->getBody();
if($response) echo $response;
else echo "null";
}
function Test04(){
copy("http://www.bilientsvc.net/Tests/TestImage02.jpg", './TestImage021.jpg');
}
function Test05(){ // XML Parsing
$pageContents = file_get_contents("http://www.bilientsvc.net/Tests/PHPXML01.php");
$result_xml = simplexml_load_string($pageContents);
//print_r($result_xml);
echo $result_xml->employee[0]->firstName;
}
function Test06(){ // HTML Parsing, Completed, 2018.08.20
// https://www.tutorialspoint.com/php/php_dom_parser_example.htm
include "HttpClient.class.php";
//echo phpinfo();
$host = "www.bilientsvc.net";
$url = "/Tests/PHPXML02.php";
$post = array('p1'=>'Hello', 'p2'=>'World');
$client = new HttpClient($host);
if($client == null) echo "client : null";
$ret = $client->post($url, $post);
if($ret == null) echo "ret : null";
$pageContents = $client->getContent();
echo $pageContents;
echo "<br> ---------------------------------------- <br>";
$dom = new DOMDocument('1.0', 'utf-8');
//echo "DOM : ".$dom;
$dom->loadHTML($pageContents);
//echo "DOM : ".$dom;
$dom->preserveWhiteSpace = false;
$body = $dom->getElementsByTagName('body');
$data = $body->item(0)->getElementsByTagName('data');
$Emp1 = $data->item(0)->getElementsByTagName('employee');
//$data1s = $data->item(0)->saveXML();
echo $Emp1->item(0)->nodeValue;
echo "<br> ---------------------------------------- <br>";
//$data11 = $data1->getElementsByTagName('employee');
//print_r($data1);
//echo $Body;
}
?>
<title>
Tests ...
</title>
</head>
<body>
<h1> PHP Post Test(Server01) </h1>
<?php
$CommandOption = $_GET['CommandOption'];
echo "-------------------------------------<br>";
echo "Command Option : ".$CommandOption."<br>";
echo "-------------------------------------<br>";
if($CommandOption == '1'){
echo "Run Test01()";
Test01();
}
if($CommandOption == '2') Test02();
if($CommandOption == '3') Test03();
if($CommandOption == '4') Test04();
if($CommandOption == '5') Test05();
if($CommandOption == '6') Test06();
?>
</body>
</html>
https://bilient-power-manager.tistory.com/2
반응형
'SWDesk > Web' 카테고리의 다른 글
[BMS] Bilient Monitoring System - Test02 (3) | 2020.03.29 |
---|---|
[Web] 공공데이터 활용 - 나라장터 (0) | 2020.02.27 |
Javafx용 예제(1) (0) | 2020.01.22 |
[MySQL] DB 백업 및 복원 (0) | 2020.01.20 |
Kotlin Excersing Example (0) | 2019.12.13 |
반응형
250x250
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 심심풀이치매방지기
- 빌리언트
- DYOV
- 아두이노
- 치매
- 티스토리챌린지
- Innovations&Hurdles
- 허들
- 혁신과허들
- 절연형
- arduino
- 전압전류모니터링
- Decorator
- 둎
- 심심풀이
- 배프
- 치매방지
- 혁신
- BSC
- 전압
- bilient
- image
- Hurdles
- Video
- 오블완
- 전류
- Innovation&Hurdles
- badp
- ServantClock
- Innovations
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
글 보관함