ping / instagram_private_api

A Python library to access Instagram's private API.
MIT License
2.94k stars 608 forks source link

How to approve user's follow request? #399

Open VityaSchel opened 1 year ago

VityaSchel commented 1 year ago

Please follow the guide below


Before submitting an issue, make sure you have:

Which client are you using?


Describe your Feature Request:

Well this is just ridiculous. In this library, there is a method to check incoming follow requests, but no way to approve it. In library with the same name but for javascript, there is a method to approve follow requests, but not to check list of them.

telegram-cloud-document-5-6138909705222751918

Please implement it! friendship_create just follows user, but does not approves its outgoing follow request. If such method exists, please add it to the documentation :)

VityaSchel commented 1 year ago

Here you can see that library uses "approve" endpoint:

https://github.com/dilame/instagram-private-api/blob/623a348343e34058c3a286693740aa3698aed3cc/src/repositories/friendship.repository.ts#L47

So all you need to do is to add a method here:

https://github.com/ping/instagram_private_api/blob/0fda0369ac02bc03d56f5f3f99bc9de2cc25ffaa/instagram_private_api/endpoints/friendships.py

VityaSchel commented 1 year ago

Ah, of course, this library is dead and even if I wanted to do a PR, it would never be accepted by author who better add funding notice than fix bug. I wonder if python has patch-package like js or I'll have to go back to dinosaurs and make a fork, edit it, and then clone to my project

VityaSchel commented 1 year ago

Here is a patch file if you know how to use it:

--- friendships.py  2022-09-17 19:43:02.000000000 +0400
+++ /venv/lib/python3.9/site-packages/instagram_private_api/endpoints/friendships.py    2022-09-17 19:43:26.000000000 +0400
@@ -356,6 +356,20 @@
             params=params)
         return res

+    def approve_user(self, user_id):
+        """
+        Approve a user's follow request.
+
+        :param user_id:
+        :return:
+        """
+        params = {'user_id': user_id, 'radio_type': self.radio_type}
+        params.update(self.authenticated_params)
+        res = self._call_api(
+            'friendships/approve/{user_id!s}/'.format(**{'user_id': user_id}),
+            params=params)
+        return res
+
     def remove_follower(self, user_id):
         """
         Remove a follower.

And if you don't know, add this to (your lib folder)/instagram_private_api/endpoints/friendships.py:

    def approve_user(self, user_id):
        """
        Approve a user's follow request.

        :param user_id:
        :return:
        """
        params = {'user_id': user_id, 'radio_type': self.radio_type}
        params.update(self.authenticated_params)
        res = self._call_api(
            'friendships/approve/{user_id!s}/'.format(**{'user_id': user_id}),
            params=params)
        return res
VityaSchel commented 1 year ago

Tested on Instagram app, works correctly.