2017-05-17 3 views
0

이 경우 구글 API를 v3의 달력json에서 php 객체를 가져 오는 방법은 무엇입니까?

$array = $client->getAccessToken(); 

덤프 $ 배열 내가 [ "refresh_token도"] 값을 얻으려면

$array = { ["access_token"]=>"i81bIkE" ["token_type"]=>"Bearer" ["expires_in"]=>3600 ["refresh_token"]=>"G3LQL_cQ" ["created"]=> 1495019807 } 

.

$refresh_token = $array -> refresh_token; 
나는이 코드를 시도

하지만 오류

$token_array = json_decode($array); 

오류 메시지

Warning: json_decode() expects parameter 1 to be string, array given in... 

plese 도움이 당신에게로 ...

답변

0

@Andy이, 당신이 할 수있는 ' 이것을 array과 함께 사용하십시오.

당신이 사용 했 :

는 [ 'refresh_token도'] $ 배열을 에코;

+0

감사합니다 timiTao, 매우 부끄럽지만 –

0

json_decode은 문자열 매개 변수가있는 PHP 메소드입니다. array을 전달하려고합니다.

refresh_tokenstring입니다. 할 수있는 일은 다음과 같습니다.

$refresh_token = $array['refresh_token']; 

+1

감사합니다. –

+0

다행이 당신을 도왔습니다 :) – Zooly

관련 문제