curl 로 보낸 요청의 로그 보는 방법

curl 로 보낸 요청의 로그 보는 방법

QA

curl 로 보낸 요청의 로그 보는 방법

본문

이전질문에서 외부API 요청시 파라메터가 빠진체 가던 오류가 있었습니다.

 

postman에서 요청하고 성공한 값들을 그대로 넣고 테스트 하던거라 당황했는데 아직 php 개발이 서툰 저로썬 로그를 쉽게 볼수있는게 있으면 좋겠다는 생각으로 질문 올려요

 

아래 postman을 통한 요청시 로그를 통해 외부api개발자들과 소통하여 값들을 수정해서 요청을 성공할수있었습니다. 

 

php curl로 요청시 이런 log를 볼수있게 하려면 어떻게 해야하나요?

 


▶GET https://외부 API 호스트 서버/api/url 200255 ms

	
	▶Network



▶Request Headers
sejongApiKey: apikey....
Content-Type: multipart/form-data; boundary=--------------------------842459623629619711423329
User-Agent: PostmanRuntime/7.28.0
Accept: */*
Cache-Control: no-cache
Postman-Token: cc010214-845a-4543-8481-...
Host: 외부 API 호스트 서버
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Content-Length: 306

	
	▶Request Body

		
		 pram1: "pram"

		
		 pram2: "pram"

	
	


▶Response Headers
Server: nginx
Date: Tue, 22 Jun 2021 09:31:13 GMT
Content-Type: text/plain;charset=UTF-8
Content-Length: 126
Connection: keep-alive
Front-End-Https: on
▶Response Body
 
{"code":"509","message":"무언가의 에러"}

이 질문에 댓글 쓰기 :

답변 2




 
 
    curl_setopt($ch, CURLOPT_VERBOSE, 1);
    $fp = fopen(dirname(__FILE__).'/log.txt', 'w');
    curl_setopt($ch, CURLOPT_STDERR, $fp);
 
    

 

추가해보세요. log.txt에 담겨져있을겁니다.

이렇게 나와줍니다.

* Hostname was found in DNS cache
* Hostname in DNS cache was stale, zapped
*  Trying 외부 API 호스트 서버...
* Connected to 외부 API 호스트 서버 (외부 API 호스트 서버) port 000 (#71)
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-...
* Server certificate:
* subject: C=KR; ST=Seoul; L=Gangdong-gu; OU=Dev Team; O=Sejong Telecom,Inc.; CN=*.url.co.kr
* start date: 2019-07-09 02:30:54 GMT
* expire date: 2021-08-25 05:51:10 GMT
* subjectAltName: 외부 API 호스트 서버 matched
* issuer: C=BE; O=GlobalSign nv-sa; CN=GlobalSign RSA OV SSL CA 2018
* SSL certificate verify result: self signed certificate in certificate chain (19), continuing anyway.
> POST url HTTP/1.1
Host: 외부 API 호스트 서버
Accept: */*
Content-Type: application/x-www-form-urlencoded;multipart/form-data;
ApiKey: apiKey...
Content-Length: 779

* upload completely sent off: 779 out of 779 bytes
< HTTP/1.1 200 OK
* Server nginx is not blacklisted
< Server: nginx
< Date: Thu, 24 Jun 2021 02:14:20 GMT
< Content-Type: application/json
< Content-Length: 51
< Connection: keep-alive
< Front-End-Https: on
<
* Connection #71 to host 외부 API 호스트 서버 left intact

툴을 바꾸어 보시는게 어떠실지

https://install.advancedrestclient.com/install

 

대충 생긴거 이렇게 생겼고, post, get 등등 헤더값이랑 다 바꿀수 있고 무료임

Advanced REST Client

3717485262_1624501155.0119.png

 

 

오류 값 등등도 다 표시됨

답변을 작성하시기 전에 로그인 해주세요.
전체 95
QA 내용 검색
filter #curl ×

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT