0
$repo=new \GuzzleHttp\Client(['headers' =>['Accept' => 'application/json',
'Content-Type' => 'application/json',
'Authorization' => 'Bearer '.$token,
]);
$promise = $repo->get('https://api.github.com/user');
$results = json_decode((string)$promise->getBody(),true);
array:30 [
"login" => "Saurabh0707"
"id" => 21239898
"avatar_url" => "https://avatars2.githubusercontent.com/u/21239898?v=4"
"gravatar_id" => ""
"url" => "https://api.github.com/users/Saurabh0707"
"html_url" => "https://github.com/Saurabh0707"
"followers_url" => "https://api.github.com/users/Saurabh0707/followers"
"following_url" => "https://api.github.com/users/Saurabh0707/following{/other_user}"
"gists_url" => "https://api.github.com/users/Saurabh0707/gists{/gist_id}"
"starred_url" => "https://api.github.com/users/Saurabh0707/starred{/owner}{/repo}"
"subscriptions_url" => "https://api.github.com/users/Saurabh0707/subscriptions"
"organizations_url" => "https://api.github.com/users/Saurabh0707/orgs"
"repos_url" => "https://api.github.com/users/Saurabh0707/repos"
"events_url" => "https://api.github.com/users/Saurabh0707/events{/privacy}"
"received_events_url" => "https://api.github.com/users/Saurabh0707/received_events"
"type" => "User"
"site_admin" => false
"name" => "Saurabh Verma"
"company" => "Software-Incubator"
"blog" => "https://github.com/orgs/Software-Incubator/dashboard"
"location" => "Ghaziabad, India"
"email" => null
"hireable" => null
"bio" => null
"public_repos" => 6
"public_gists" => 0
"followers" => 0
"following" => 0
"created_at" => "2016-08-25T11:01:02Z"
"updated_at" => "2017-09-11T03:35:05Z"
]
나는 적절한 json으로 변환 할 수 없습니다. 반환 된 PHP 스트림의 로그인 키에 대한 값에 액세스 할 수 없습니다. 나는 또한 그것을 json으로 변환 할 수 없다. 어떻게 액세스 할 수 있습니까?응답을 guzzle 클라이언트가 json 배열로 되 돌린 응답을 변환하십시오.
$results = json_decode((string)$promise['login]->getBody(),true);
을하지만 유효하지 않습니다 나는 노력했다.
이미 시도했습니다 .. !! –