【发布时间】:2017-07-05 17:57:07
【问题描述】:
我正在使用 Instagram 包 vinkla 将用户数据获取到我的应用程序。
这是我用来获取结果的代码:
public function instagram()
{
$insta = new Instagram();
$getUser = $insta->get('gopro');
dd($getUser);
}
当我死转结果时,我会在返回时得到这个数组:
array:20 [▼
0 => {#205 ▼
+"id": "1552323772757218591_28902942"
+"code": "BWK9j8rlpUf"
+"user": {#208 ▶}
+"images": {#202 ▼
+"thumbnail": {#203 ▶}
+"low_resolution": {#214 ▶}
+"standard_resolution": {#204 ▼
+"width": 640
+"height": 640
+"url": "https://scontent-frt3-1.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/19624693_104174916895493_9107740182827761664_n.jpg"
}
}
+"created_time": "1499271435"
+"caption": {#207 ▶}
+"likes": {#215 ▶}
+"comments": {#222 ▶}
+"can_view_comments": true
+"can_delete_comments": false
+"type": "image"
+"link": "https://www.instagram.com/p/BWK9j8rlpUf/"
+"location": {#223 ▶}
+"alt_media_url": null
}
1 => {#224 ▶}
2 => {#251 ▶}
3 => {#278 ▶}
]
现在我要解决的问题:
我想在我的 laravel 应用程序中集成一些图像。基本上我想从每个数组 images->standard_resolution->url 中获取图像 url。
到目前为止,我尝试使用 double foreach 迭代数组,但没有成功。
关于如何实现这一点的任何建议?
【问题讨论】:
-
请提及正在使用的包并显示您用于迭代的代码。
-
请尝试
$getUser->pluck(['images.standard_resolution.url'])->where('type', 'image')->toArray()。 -
@user2094178 我得到:调用数组上的成员函数 pluck()
-
collect([$getUser])->pluck(['images.standard_resolution.url'])->where('type', 'image')->toArray() -
@user2094178 我得到一个空数组返回 []
标签: php arrays laravel api instagram