API follow



Helo twitter community !
I have a little trouble with my website and the twitter API
i explain to you :
I managed to save my 3 last subscriber :

$tweet->get('followers/list', array('screen_name' => 'audothomas', 'count' => 3));

until now, everything works well, but i want to add a feature :
i want to follow these 3 account automatically ! I spent a lot of time trying to resolve this problem but i dont find any solutions :cry:
If someone can say to me how to do, i will be very gratefull
Sorry for my bad english, i did the best that i can
Thanks for reading me, have a good day ! :slight_smile:


You would need to combine it with this endpoint: https://dev.twitter.com/rest/reference/post/friendships/create


thx for your reply but i’ve already seen this, can you give me some ideas to move forward please ? I have a lack of idea :sweat_smile:


Loop over the last 3 users you saved and create the friendship with them if one doesn’t exist using the endpoint I provided.


thx man, i have read this but its very technical, and, for a begginer like me its difficult to understand everything :confused:

So i think that my code is almost finished :

$t = json_decode($tweet->get(‘followers/list’, array(‘screen_name’ => ‘monsieurdream’, ‘count’ => 2)), true);
foreach ($t[‘users’] as $user) {
$tweet->post(‘friendships/create’, array(‘screen_name’ => $user[‘screen_name’]));
$out = $out.“Username “.$user[‘screen_name’].” ID “.$user[‘id_str’].”
echo $out;
// fichier qui garde en memoire
file_put_contents(‘followers.txt’, $out);
echo “done”;ode here

This, successfully print on my webpage the name and id of the 2 last follower of the account "monsieurdream", but i want to follow these 2 accounts and my : 

$tweet->post(‘friendships/create’, array(‘screen_name’ => $user[‘screen_name’]));

 ; doesn't work, if you can help me a second time i will be very gratefull ! :slight_smile: