0
PHP를 통해 cURL을 사용하여 서비스 연결을 테스트하고 있는데 일치하지 않는 결과가 나타납니다. 내 브라우저의 응답이 짧은 절단PHP GET 요청이 일치하지 않는 결과를 반환합니다.
{"response":"\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\n<head>\n <link href=\"/images/global/global.css\...and so on
: 내 브라우저에서 동일한 URL을 넣어
{"response":"\n\n\n\n \n \n
나는이 얻을 : 나는 PHP & 컬를 통해 테스트를 실행하면이 내 결과입니다 그러나 당신은 아이디어를 얻는다.
내 PHP에서는 JSON 파일을 읽고 필요한 URL을 구문 분석하고 cURL을 사용하여 GET 요청을 보냅니다.
내가 얻을 수<?php
include ("serviceURLs.php");
class callService {
function testService($url){
$ch = curl_init($url);
curl_exec($ch);
$info = curl_getinfo($ch);
if ($info['http_code'] == 200){
echo("Test has passed </br>");
}else{
echo("Test Failed.</br> ");
}
var_dump($info);
curl_close($ch);
}
function readFile(){
$myFile = "./service/catalog-adaptation.json";
$fr = fopen($myFile, 'r');
$fileData = fread($fr, filesize($myFile));
$json_a = json_decode($fileData, TRUE);
$prodServer = $json_a['serverRoots']['%SERVER_ROOT']['PROD'];
$demoServer = $json_a['serverRoots']['%SERVER_ROOT']['DEMO'];
$testServer = $json_a['serverRoots']['%SERVER_ROOT']['TEST'];
$testUrls = $json_a['commands'];
foreach($testUrls as $tURL){
$mURL = $tURL['URL'];
if(stripos($mURL, "%")===0){
$testTestService = str_replace("%SERVER_ROOT", $testServer, $mURL);
$testDemoService = str_replace("%SERVER_ROOT", $demoServer, $mURL);
$testProdService = str_replace("%SERVER_ROOT", $prodServer, $mURL);
echo ("Production test: ");
$this->testService($testProdService);
echo ("Demo test: ");
$this->testService($testDemoService);
echo ("Test test: ");
$this->testService($testTestService);
}
}
}
}
$newServiceTest = new callService;
$newServiceTest->readFile();
?>
사람이 내 이유는 무엇입니까 다른 결과를 말할 수 나는 내 코드를 해결할 수있는 방법을 일관된 결과 : 여기 PHP를 통해 서비스를 테스트하기 위해 사용하고있는 코드는?
위대한 답변! 고맙습니다! 완벽하게 일했습니다! – BlackHatSamurai