Show a follower's display picture URL for a specified user. 1.1 API


#1

Hi,

I have tried to get my code to work. I am wanting a way to show follower’s twitter profile picture.

I am using Abraham’s twitteroauth and I have already connected it to my Twittter account.

currently I am using this code, but it doesen’t work:

<?php
$followers = $connection->get("https://api.twitter.com/1.1/followers/list.json?cursor=-1&screen_name=ryanfitton");

foreach($followers as $response){
	echo $followers->user->profile_image_url;
}
?>

Although if I print the array using:

print_r($followers);

It will show the code,

Thanks,
Ryan


#2

Ryan —

Without delving too deeply into your code, you might have a nesting issue. The response for the /1.1/followers/list.json endpoint is cursored, which means that it will have the following format:

{ "users": [ // users here, which the profile_image_url key ], "next_cursor": 1433334151278313797, "next_cursor_str": "1433334151278313797", "previous_cursor": 0, "previous_cursor_str": "0" }

Cheers,

Vince