使用 php 在 stdClass 对象中检索标签

Retrieve a tag in a stdClass Object with php

我正在尝试使用此代码检索 [followed_by] 标签。但是没用。

-- Instagram returns :

 stdClass Object
(
  [meta] => stdClass Object
    (
        [code] => 200
    )

[data] => stdClass Object
    (
        [username] => kenzasmg
        [bio] => Based in Paris | Twitter : @KenzaSMG | Facebook : La Revue de Kenza | Snapchat 👻 : KenzaSMG | kenzasmg@gmail.com
        [website] => http://larevuedekenza.fr/
        [profile_picture] => https://instagramimages-a.akamaihd.net/profiles/profile_3169582_75sq_1365288071.jpg
        [full_name] => Kenza  Sadoun - El Glaoui
        [counts] => stdClass Object
            (
                [media] => 5144
                [followed_by] => 76722
                [follows] => 250
            )

        [id] => 3169582
    )

)

我的 php 代码:

$result = $instagram->getUser(3169582);

echo '<pre>';
print_r($result);
echo '<pre>';

foreach ($result->data as $data) {

$followed = $data->counts->followed_by;
}

print($followed);
foreach ($result->data as $data)

给你[用户名],[生物]...[计数] ..所以,你不能问data->counts->followed_by; 试试看:

$followed = $result->data->counts->followed_by;