php - PHP 错误:未定义的属性:当 property_exists 为 true 时 stdClass::$access_token
问题描述
我在使用 PHP5 的身份验证回调中收到以下错误:
Undefined property: stdClass::$access_token
这是代码:
$result = curl_exec($ch);
$data = json_decode($result);
var_dump(property_exists($data, 'access_token'));
var_dump($data);
var_dump($data->access_token);
$token = $data->access_token;
这是该代码的结果:
bool(true)
object(stdClass)#1 (5) { ["access_token"]=> string(36) "pretend-code-is-here" ["token_type"]=> string(6) "bearer" ["expires_in"]=> int(3600) ["refresh_token"]=> string(36) "pretend-code-is-here" ["scope"]=> string(8) "identity" }
string(36) "pretend-code-is-here"
该代码与特定的 var_dump 匹配,但我无法将其分配给 $token 而不会出现该错误,并且我无法在以下请求中使用它。
解决方案
推荐阅读
- mysql - SQL 任务,如果产品在给定月份没有销售,则在本月显示 0
- javascript - Fullcalendar 事件颜色 MySQL
- playframework - 播放框架“runProd”不接受自定义配置文件
- c++ - 从 ostringstream 读取/写入会更改原始数据
- python - 使用 Dockerfile RUN 而不是 CMD 传递环境变量
- java - 如何启用firebase离线数据并将数据传递给recyclerview适配器?
- python - 是否可以在 Django 模板中过滤“相关字段”?
- php - 如果在数据库中找不到条目,我如何获得所需的值
- jquery - 用户单击链接并重定向时如何保持子菜单不折叠
- c# - 如何转换 ReadOnlyMemory
到只读存储器