테스트 사이트 - 개발 중인 베타 버전입니다

curl $data = json_decode($response, true); null 값 질문 드립니다. 채택완료

cho개발 5년 전 조회 2,094

url_setopt($ch, CURLOPT_URL, $url.$queryParams); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_HEADER, FALSE); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET'); $response = curl_exec($ch); curl_close($ch); $data = json_decode($response, true); print_r($response);

 

일단 $resopnse까지는 값을 잘 불러오는데

json_decode 한뒤로 var_dump($data)를 하면 null값이 나옵니다..

 

 

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

답변 2개

채택된 답변
+20 포인트

print_r($response);

이렇게 하면 값이 어떻게 나오나요?

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

답변에 대한 댓글 4개

쟁반짜장
5년 전
그냥 문자열이 리턴되는 건가요?
사용 중이신 api url 알려주실 수 있나요?
쟁반짜장
5년 전
$datas = json_decode($response);
foreach($datas->response->body->items as $key => $value) {
echo $value->baseTime;
}
이렇게 해 보세요.
쟁반짜장
5년 전
dataType을 json으로 넘겨 보세요.
http://exam.dothome.co.kr/temp/wrid_359647.php
c
cho개발
5년 전
_type에서 dataType 요청변수 문제였네요.. 댓글감사합니다

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

toqurk
5년 전

print_r($data); 로 해서 한번 보시죠...배열로 왔을건데..json이면

 

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

답변에 대한 댓글 1개

c
cho개발
5년 전
print_r($data)로 하면 아무것도 출력이 안되요..

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

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

로그인