pgrimaud / instagram-user-feed

This is a scrapper to easily fetch any feed and interact with Instagram (like, follow, etc.) without OAuth for PHP.
MIT License
881 stars 137 forks source link

How can I use proxies with multi account? #89

Closed manguon closed 4 years ago

manguon commented 4 years ago

Hi everybody

Instagram can lock or restrict login at any time.

So I want to use multiple accounts in combination with proxies.

Suppose, I have the following proxies:

1.1.1.1 2.2.2.2 3.3.3.3 4.4.4.4

And the following Instagram accounts: [[USERNAME / PASSWORD]]

instaguser1 / passwd instaguser2 / passwd instaguser3 / passwd instaguser4 / passwd

All accounts have the same password (passwd).

@pgrimaud How can I use proxies in combination with accounts in credentials.php file (examples folder)

Thank you so much !

pgrimaud commented 4 years ago

First, I allow to save in cache multiple instagram sessions : https://github.com/pgrimaud/instagram-user-feed/commit/3acdcd172d4ea743fb2b3455ccfa9af50b922f8f (previously it was not possible, only one session was saved in cache).

Then I added an example for using proxies here : https://github.com/pgrimaud/instagram-user-feed/blob/master/examples/using-proxies.php

$client = new Client([
    'proxy' => [
        'https' => '91.209.25.156:8080'
    ]
]);

$api = new Api($cachePool, $client);
$api->login('login', 'password');

// do what you want with this proxy and this instagram account

I found the proxy here : http://www.freeproxylists.net/?c=&pt=&pr=HTTPS&a%5B%5D=0&a%5B%5D=1&a%5B%5D=2&u=90

Then you just have to implement you own strategy to :

manguon commented 4 years ago

Thanks for your support.

Is there a way to declare proxy in credentials.php file? (Then, each login time, use the variable <$proxy> to call the proxy)

ex:

$client = new Client([
    'proxy' => [
        'https' => $proxy
    ]
]);

$api = new Api($cachePool, $client);
$api->login('login', 'password');
pgrimaud commented 4 years ago

The credentials file is modular. I created it only for the examples, so you cant change it without any problem.

You also can create an array with all the credentials like that :

<?php

$credentials = [
    [
        'login'    => 'username1',
        'password' => 'passwd',
        'proxy'    => '1.2.3.4:1234',
    ],
    [
        'login'    => 'username2',
        'password' => 'passwd',
        'proxy'    => '1.2.3.5:1235',
    ], 
   ...
];

$user = $credentials[rand(0, count($credentials) - 1)];
print_r($user);

I will select a random user in this array

manguon commented 4 years ago

On version 6.3, it works very well.

Thank you very much @pgrimaud