How to check Instagram username availability

柔情痞子 提交于 2019-12-13 22:39:16

问题


how to check if the username is available or not in Instagram, i tried using Get request and catch 404 error, it dose not work sometimes, is there another way ? a reliable one?

i tried using object pascal

 try
        lHTTP.Get('http://instagram.com/'+lPath, TStream(nil));
      except
        on E: EIdHTTPProtocolException do
        begin
          if E.ErrorCode = 404 then
          begin
            TThread.Synchronize(nil,
              procedure
              begin
                Form1.Memo2.Lines.Add(lPath);
                 Label2.Text:= IntTosTr(Memo2.Lines.Count);
              end
            );
          end;
          Exit;
        end;
      end;

but sometimes, when it returns 404 i go and check if user exist in instagram, but i cant find it and i cant register with the user, it says user is unavailable!

is there instagram api function that i can use it to check if user is available ? i realised that some accounts are closed! how to differentiate if its closed or taken or available ?

UPDATE

i think maybe this could be answer, but im not sure how to use it in delphi, How do I check if a username is taken with parse.com when all User ACL:Public read/write is disable?


回答1:


This is very dirty. Complete the code on your own using these instructions

GET this url (to get cookies)

https://www.instagram.com/accounts/web_create_ajax/attempt/

POST to this url again

https://www.instagram.com/accounts/web_create_ajax/attempt/

with these values

  • referer: https://www.instagram.com/
  • new (custom) header named "x-csrftoken", value copy from cookie "csrftoken" which you received from GET

POST values

  • email=... some random e-mail which does not exist on instagram ...
  • password=... some strong password ...
  • username=... your name ...
  • first_name=... empty

You will get result like this if account can be created

{... "status": "ok", "username_suggestions": ["..."], "account_created": false}

or this if not

{..."status": "ok", "username_suggestions": ["..."], "errors": {"username": ["Sorry, that username is taken."]}, "account_created": false}




回答2:


Your API call example contains errors.

When I try

https://api.instagram.com/v1/users/search?q=rn0&access_token=xxxxxxxxxxxxxx

the server answers

{"meta": {"error_type": "OAuthAccessTokenException", "code": 400, 
  "error_message": "The access_token provided is invalid."}}

As I do not have a access_token, I can't test more than this, but maybe it gets you started



来源:https://stackoverflow.com/questions/37234274/how-to-check-instagram-username-availability

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!