{"action":"created","issue":{"url":"https://api.github.com/repos/timgrossmann/InstaPy/issues/2978","repository_url":"https://api.github.com/repos/timgrossmann/InstaPy","labels_url":"https://api.github.com/repos/timgrossmann/InstaPy/issues/2978/labels{/name}","comments_url":"https://api.github.com/repos/timgrossmann/InstaPy/issues/2978/comments","events_url":"https://api.github.com/repos/timgrossmann/InstaPy/issues/2978/events","html_url":"https://github.com/timgrossmann/InstaPy/pull/2978","id":362756301,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE3Mzg3NjQ2","number":2978,"title":"Bunch of improvement and solution for the latest bugs out of misbehaviours known as 'not connected' & 'log-out' issues","user":{"login":"uluQulu","id":33269249,"node_id":"MDQ6VXNlcjMzMjY5MjQ5","avatar_url":"https://avatars3.githubusercontent.com/u/33269249?v=4","gravatar_id":"","url":"https://api.github.com/users/uluQulu","html_url":"https://github.com/uluQulu","followers_url":"https://api.github.com/users/uluQulu/followers","following_url":"https://api.github.com/users/uluQulu/following{/other_user}","gists_url":"https://api.github.com/users/uluQulu/gists{/gist_id}","starred_url":"https://api.github.com/users/uluQulu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uluQulu/subscriptions","organizations_url":"https://api.github.com/users/uluQulu/orgs","repos_url":"https://api.github.com/users/uluQulu/repos","events_url":"https://api.github.com/users/uluQulu/events{/privacy}","received_events_url":"https://api.github.com/users/uluQulu/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":20,"created_at":"2018-09-21T20:03:52Z","updated_at":"2018-09-25T17:55:24Z","closed_at":"2018-09-25T11:30:39Z","author_association":"COLLABORATOR","pull_request":{"url":"https://api.github.com/repos/timgrossmann/InstaPy/pulls/2978","html_url":"https://github.com/timgrossmann/InstaPy/pull/2978","diff_url":"https://github.com/timgrossmann/InstaPy/pull/2978.diff","patch_url":"https://github.com/timgrossmann/InstaPy/pull/2978.patch"},"body":"Hello\r\n\r\nHaving caught a terribly seasonal grip I will be short in description and for that reason I made the commits highly separate for you to understand.\r\n\r\nThe only thing needs to be mentioned is,\r\nWhile getting the username from the user ID using the IG Follow endpoint- \r\n`https://www.instagram.com/web/friendships/{user_id}/follow/`\r\nit was sometimes logging out and redirecting to the\r\n`https://www.instagram.com/accounts/login/?next=/web/friendships/{user_id}/follow/`\r\nwebpage after logging out the user.\r\n\r\nI have talked about debugging it at #2953 in details - special thanks to @spikeyhair for great feedback.\r\n\r\nAfter having diagnosed the issue, I have offered different approaches to do it- getting the username from the user ID.\r\nNow, it has 3 steps:\r\n#### method using graphql 'Account media' endpoint\r\n+ It loads a posts of a user from the give user ID then gets the shortcode of a post and navigates to it and the gets the username from there as usual.\r\n+ It's using the same graphql URL- \"https://www.instagram.com/graphql/query/?query_hash={}\" we use for relationship tools and is super stable.\r\n+ It has drawbacks- can load posts of users only if it is non-private [or private and is being followed] and works only the user has a post [photo or video]\r\n#### method using private API\r\n`https://i.instagram.com/api/v1/users/{user_id}/info/`\r\n+ If you disagree, I can remove that method easily but I think it is cool link and has no problem and also is optional and we do not rely on it.\r\n+ Good news is it gets the username of any user- private or non-private\r\n\r\n#### method using graphql 'Follow' endpoint\r\nThe same method with the bug- `https://www.instagram.com/accounts/login/?next=/web/friendships/{user_id}/follow/`\r\n+ If you disagree, we can remove it. But note that this 3rd step is gonna be requested only in rare cases cos almost everytime prior 2 steps will get the username.\r\n\r\n----\r\n\r\nCheers 🙋🏼‍♂️\r\n-----"},"comment":{"url":"https://api.github.com/repos/timgrossmann/InstaPy/issues/comments/424440669","html_url":"https://github.com/timgrossmann/InstaPy/pull/2978#issuecomment-424440669","issue_url":"https://api.github.com/repos/timgrossmann/InstaPy/issues/2978","id":424440669,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNDQ0MDY2OQ==","user":{"login":"sionking","id":7851877,"node_id":"MDQ6VXNlcjc4NTE4Nzc=","avatar_url":"https://avatars2.githubusercontent.com/u/7851877?v=4","gravatar_id":"","url":"https://api.github.com/users/sionking","html_url":"https://github.com/sionking","followers_url":"https://api.github.com/users/sionking/followers","following_url":"https://api.github.com/users/sionking/following{/other_user}","gists_url":"https://api.github.com/users/sionking/gists{/gist_id}","starred_url":"https://api.github.com/users/sionking/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sionking/subscriptions","organizations_url":"https://api.github.com/users/sionking/orgs","repos_url":"https://api.github.com/users/sionking/repos","events_url":"https://api.github.com/users/sionking/events{/privacy}","received_events_url":"https://api.github.com/users/sionking/received_events","type":"User","site_admin":false},"created_at":"2018-09-25T17:55:24Z","updated_at":"2018-09-25T17:55:24Z","author_association":"COLLABORATOR","body":"@uluQulu I am not fully understand Y not also checking this before get_following_status to save time.\r\n\r\nyou can have (ugly)\r\n```\r\n        # find out following status\r\n        if not is_page_available:\r\n            following = None\r\n            follow_button = None\r\n        else:\r\n            following, follow_button = get_following_status(browser, person, logger)\r\n```"}}
{"actor":{"display_login":"sionking"}}