2017-10-30 21 views
0
from fbchat import Client 
from fbchat.models import * 

client = Client('<username>', '<password>') 

print('Own id: {}'.format(client.uid)) 

client.send(Message(text='Hi me!'), thread_id='clientname', thread_type=ThreadType.USER) 

client.logout() 

上記のコードサンプルは、私がチュートリアルのオンラインから入手したものです。プログラムはFacebookメッセンジャーにログインしてユーザーIDを教えてくれます。それから私はclient.sendにFacebookのメッセンジャーを使って実際に私の連絡先の1つにメッセージを送信するかどうかを確認しましたが、IDLEでこれを取得します。誰でもこの問題の解決策を提供できますか?pythonでfbchatを使用してメッセージを送信できません

Traceback (most recent call last): 
    File "C:/Users/User/Desktop/Python/fbchat trial.py", line 10, in <module> 
    client.send(Message(text='Hi me!'), thread_id='User', thread_type=ThreadType.USER) 
    File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\fbchat\client.py", line 955, in send 
    return self._doSendRequest(data) 
    File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\fbchat\client.py", line 923, in _doSendRequest 
    j = self._post(self.req_url.SEND, data, fix_request=True, as_json=True) 
    File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\fbchat\client.py", line 128, in _post 
    raise e 
    File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\fbchat\client.py", line 124, in _post 
    return check_request(r, as_json=as_json) 
    File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\fbchat\utils.py", line 193, in check_request 
    raise FBchatFacebookError('Error when sending request: Got {} response'.format(r.status_code), request_status_code=r.status_code) 
fbchat.models.FBchatFacebookError: Error when sending request: Got 500 response 
+0

client.uid' – yash

答えて

1

これを試す必要があります。あなたのthread_idが間違っていると思います。

client.send(Message(text='Hi me!'), thread_id=client.uid, thread_type=ThreadType.USER) 
+0

'に変更thread_idは値を私は他の人にメッセージを送信したい場合ので、私は、クライアントIDにclient.uidを変更します? –

+0

@RSそれは正しいです。このプログラムはあなたにメッセージを送ります:D。あなたと話していない限り、あなたは何をしたいですか? – hahahakebab

+0

@RSこれがあなたの質問に答える場合は、スレッドを閉じてください。 – hahahakebab

関連する問題