fetch data from an object

前端 未结 2 1646
粉色の甜心
粉色の甜心 2021-01-28 07:16

I am trying to fetch data from user\'s twitter account with this code

$user_info = $twitteroauth->get(\'account/verify_credentials\');

i get

相关标签:
2条回答
  • 2021-01-28 08:01

    The information is not an array, but an object. You can access the data by the following:

    $info = $user_info->description;

    You can repeat this by to go further down the chain such as:

    $user_info->entities->description, etc.

    0 讨论(0)
  • 2021-01-28 08:08

    You are trying to access a object with the array index syntax it will not work this way.

    When you are dealing with objects you need to access the array by using "->"

    $user_info->name;
    $user_info->entities->description;
    $user_info->entities->description->urls;
    

    This is the pattern to access to the depth

    0 讨论(0)
提交回复
热议问题