用python 檢查LINE ID 是不是存在

Posted in :

我想知道某一個 LINE ID, 是不是存在的,研究了LINE官方的 LINE BOT:
https://developers.line.me/restful-api/overview

發現並對我而言,官方目前提供的API我都用不到,這些API似乎是開放給一般的公司行號用,針對LINE官方的BOT這一篇寫的還不錯:

[教學] Line BOT API
http://huli.logdown.com/posts/726082-line-bot-api-tutorial


相關文章:

用 LINE API 打造自動回話機器人-2015/8/24更新
https://www.mxp.tw/2015/04/30/%E7%94%A8-line-api-%E6%89%93%E9%80%A0%E8%87%AA%E5%8B%95%E5%9B%9E%E8%A9%B1%E6%A9%9F%E5%99%A8%E4%BA%BA/

Python Line API
http://dev.im-bot.com/line/

韓國神人 Taehoon Kim 的 LINE BOT:
https://github.com/carpedm20/LINE

Documentation : http://carpedm20.github.io/line/
Developer Mailing List: Google Group

使用 LINE API 傳送訊息,但目前仍有 authToken 時間過期問題
http://ssorc.tw/5907

[心得] Cacti+Line群組告警
https://www.ptt.cc/bbs/MIS/M.1414213987.A.7EF.html

但是最新版的程式被LINE公司要求移除一些code所以無法使用賬號密碼登入
只能用authtoken登入,所以我們改用舊版一點的程式
https://pypi.python.org/pypi/line/0.0.8

一些被刪掉的code, 在 0.0.8 版裡找的到。目前我是用 0.8.0 版。

切換到 0.0.8 或是 0.7.1 或是 0.8.0 都有不同的問題要決解。

  • 首先第1步要解決的登入問題,新版沒辦法登入,無法跑出要求手機輸入驗證碼,我是用 0.7.1 的 code, 讓驗證碼顯示到手機上。
  • 接著是取得 access token,這個我也是用 0.7.1 或 用 0.5.2 都可以。
  • 最後,是要從 0.0.8 版取得部份被刪除的程式碼到 0.8.0 版來用。

我遇到的問題,和下面這篇文章遇到的問題一樣:

why make private method ? some thing like _findContactByUserid() in client.py
https://groups.google.com/forum/#!searchin/line-python-developer/userid/line-python-developer/9b0MuBlkozs/4-M8hRQXBgAJ


I got the same error in this method:

Screen Shot 2016-07-30 at 04.51.17
Error: maximum recursion depth exceeded

I fixed this error by copy findContactByUserid as a new method in client.py, api.py, CurveThrift.py

I add new debug code to print message in CurveThrift.py in method:
def findContactByUserid(self, userid):

but the result is code not be executed, after copy exist code to new method the new method is executed!
after fix, userid could be search:

Screen Shot 2016-07-30 at 04.55.32

修改好後,就可以查 LINE ID 了,查失敗的結果會是有專門的 exception:

Error: Cannot find userid: XXX


你可能會問,我怎麼知道要改這些行? 因為我一直在try error 和看作者的 source code, trace 再 trace, 看了好幾個小時了, 還是看不懂作者在寫什麼東西,還好加 debug code 來 print 很簡單,初學者都會。

遇把作者 github 上的 issue, commit history, google group 上的討論看了一輪,結論:沒什麼幫助。


結合 line id 的 database,並連結上 line server 進行 userid 的檢查:

Screenshot 2016-07-30 18.38.19

LINE BOT 就完成了,真感動,真的是 May the LINE be with you…


上面的方法,已經不能用了,python 程式是對的可以用,但中間的 library 聽說需要調整才行。

接著出現的解法是透過 QR code 登入:
LineVodka
https://github.com/merkremont/LineVodka

上面解法只適用到 2017年11月,LINE官方的伺服器修改了相關的程式碼,目前會顯示這個錯誤:

File "/LineVodka/LineAlpha/LineThrift/TalkService.py", line 3490, in recv_getLastOpRevision
raise result.e
LineAlpha.LineThrift.ttypes.TalkException: TalkException(parameterMap=None, reason='LOG_OUT', code=8)

另一個解法,使用LINE 官方的 BOT API:

這個限制是,BOT最多只能服務50個人,超過的話要付費。

https://pypi.org/project/line-bot-sdk/

這個要先 create a channel:
https://developers.line.me/en/docs/line-login/getting-started/

Integrating LINE Login with your web app
https://developers.line.me/en/docs/line-login/web/integrate-line-login/

相關教學:


看看新的 line-py:

https://github.com/fadhiilrachman/line-py

目前 bot,會造成帳號的部份功能被ban:

Sometimes administrators regulate your account. The best workaround is don’t use api or don’t be bad user like kicker. If you want to avoid it but want to use api too, please see below list.

Rules

  • Talk Regulatory
    • Happen when you send too many messages.
  • AddContact Regulatory
    • Happen when you add too many contacts in a day.
  • Group Change Regulatory
    • Happen when you Invite,Kickout,Change Name,Change Invite Link too many times.
  • Timeline Post Regulatory
    • Happen when you made a too many posts in a time.
  • Timeline Comment Regulatory
    • Happen when you made a too many comments in a time.

If got Regulatory

It can login, but some features can’t use. For example, Talk Regulatory, Messages are undelivered.
Usually take a from 3 days to 1 week to get unban.(maybe)
If banned for more than 1 week, you will have to recreate an account.

 

3 thoughts on “用python 檢查LINE ID 是不是存在

  1. 你好,我想买一个查询 line ID是否存在的软件 你这边有现成的吗?急需 可以联系我QQ12648532 或者电话我+86 18649708001

    1. 沒有現成的,目前有token 會定期失效,需要使用手機讓機器人手動登入以取得token.

  2. 您好 請問您所說的關於carpedm20的library調整您有試過嗎
    因為我現在需要一個可以將人踢出群組的功能 但官方沒有提供這個API 無法連接
    能透過這個做嗎?

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *