curl 로 보낸 요청의 로그 보는 방법 채택완료

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

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

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

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

Copy
▶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개

채택된 답변
+20 포인트
Copy
curl_setopt($ch, CURLOPT_VERBOSE, 1);

    $fp = fopen(dirname(__FILE__).'/log.txt', 'w');

    curl_setopt($ch, CURLOPT_STDERR, $fp);

 

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

로그인 후 평가할 수 있습니다

답변에 대한 댓글 3개

오 감사합니다 ㅎㅎ
근데 Request Body를 볼순 없나요??
보낸 파라미터는 안나와있어서요
이렇게 나와줍니다.

* 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
curl_setopt($ch, CURLINFO_HEADER_OUT, true);

$rawdata=curl_exec($ch);

$header_info = curl_getinfo($ch, CURLINFO_HEADER_OUT);

echo $header_info;

댓글을 작성하려면 로그인이 필요합니다.

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

https://install.advancedrestclient.com/install

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

Advanced REST Client

3717485262_1624501155.0119.png

오류 값 등등도 다 표시됨

로그인 후 평가할 수 있습니다

답변에 대한 댓글 1개

댓글 감사합니다.
하지만 저에게 필요한건 php 에서 curl_exec 을 통해 요청한 log를 보고싶은거에요.
툴은 한번 살펴보겠습니다. 감사합니다.

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인
🐛 버그신고