简体   繁体   English

使用xmmp python库和谷歌应用引擎发送xmpp消息

[英]Send a xmpp message using xmmp python library and google app engine

I'm trying to send a message using xmpp and google app engine. 我正在尝试使用xmpp和谷歌应用引擎发送消息。 I'm using xmpp library for python. 我正在使用xmpp库进行python。 My code is the following: 我的代码如下:

import webapp2
import xmpp

_SERVER = 'serverdomain'

class MainPage(webapp2.RequestHandler):
    def post(self):

        msg = 'hello'

        global username 
        username = 'user'
        global passwd
        passwd = 'ssdsd'

        global xmppClient
        global to
        to='toAddress' 

        jid = xmpp.protocol.JID(username)
        xmppClient = xmpp.Client(jid.getDomain(),debug=[])
        xmppClient.connect(server=_SERVER)
        xmppClient.auth(username, passwd, 'botty')
        xmppClient.sendInitPresence()
        self.response.out.write('me conecte '+xmppClient.isConnected())
        xmppClient.send(xmppClient.Message(to, msg, type='chat'))

app = webapp2.WSGIApplication([ ('/', MainPage)], debug=True)

When I execute my test I obtain the following error 当我执行我的测试时,我得到以下错误

ImportError: No module named xmpp ImportError:没有名为xmpp的模块

over and over again. 一遍又一遍地。 I put in pythonpath the .egg xmpp library and eclipse recognized it so I can use CTRL+TAB to autocomplete., that indicates me the the editor recognize the library but no the server (GAE) so maybe I need to add the library to the server and compile it. 我在.egg xmpp库中放入pythonpath,eclipse识别它,所以我可以使用CTRL + TAB自动完成。这表明编辑器识别库但没有服务器(GAE)所​​以我可能需要将库添加到服务器并编译它。 Is that a good idea? 这是一个好主意吗? any other server suggestion? 任何其他服务器的建议? I need help please. 我需要帮助。

Thanks. 谢谢。

In Debian, had the same problem. 在Debian中,遇到了同样的问题。 In my case, I solved it installing the python-xmpp package: apt-get install python-xmpp 在我的例子中,我解决了安装python-xmpp包的问题:apt-get install python-xmpp

I hope it help you 我希望它对你有所帮助

For package details, see here: https://packages.debian.org/sid/python/python-xmpp 有关包的详细信息,请参阅此处: https//packages.debian.org/sid/python/python-xmpp

Looks like your import path is incomplete. 看起来您的导入路径不完整。 Try: 尝试:

from google.appengine.api import xmpp

Instead of 代替

import xmpp

Lots more detail here 这里有更多细节

Take a look at other questions about setting up third party libraries for GAE. 查看有关为GAE设置第三方库的其他问题。 Note that if the xmpp library is not pure python (ie uses native code), you won't be able to use it. 请注意,如果xmpp库不是纯python(即使用本机代码),您将无法使用它。

https://stackoverflow.com/search?q=google-app-engine+python+third+party+libraries https://stackoverflow.com/search?q=google-app-engine+python+third+party+libraries

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM