Tropo WebAPI 与 Drupal 模块
我正在尝试扩展 Drupal 网站的功能以包含 Tropo 服务。我绝对需要能够访问我的 Drupal 数据库以及 Drupal 为其自身工作提供的 API。我在编写 Drupal 模块方面相当新,但现在似乎发生的是 Tropo 无法将我的 .module 文件识别为 PHP,因此它不会接收必要的 JSON 调用。
我需要 a) 一种让 Tropo 从我的 .module 文件中读取的方法,或者 b) 一种将常规 .php 文件添加到我的模块中的方法,这样我仍然可以进行所有正常的 Drupal 函数调用并且 Tropo 可以访问我的脚本。
想法?
I'm trying to extend the functionality of a Drupal website to include Tropo service. I absolutely need to be able to access my Drupal database and the API that Drupal provides me for its own workings. I am fairly new at writing Drupal modules, but what seems to be happening right now is that Tropo cannot recognize my .module file as PHP, so it does not receive the JSON calls necessary.
I need either a) a way of getting Tropo to read from my .module file or b) a way of adding a regular .php file to my module such that I can still make all normal Drupal function calls AND Tropo can access my script.
Thoughts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 Drupal 中,您无法直接从 Web 运行 .module 文件。每个模块都应该实现 hook_menu 并且该钩子创建您要使用的 URL。因此,您需要向 Tropo 提供由 yourmodule_menu 创建的 URL,而不是 yourmodule.module 的路径。
例如,下面是来自 Tropo 示例模块的 hook_menu。
demo_menu 函数将 demo/answer 定义为您网站上的 URL。如果您的网站位于 example.com,您可以向 Tropo 提供您的 URL:http://example.com/demo/answer 。然后,当有人拨打您的 Tropo 电话号码时,demo_answer() 函数就会运行,说出“你好。再见”。然后挂断。
我在关于使用 Drupal 作为应用程序框架的演讲中使用了一个简单的演示模块,它可能会有所帮助 - 我在演示中广泛使用 Tropo。 https://github.com/akalsey/drupal-framework-demo
电话投票模块也将是一个很好的例子。它使用 Tropo 将语音和短信添加到 Drupal 6 的内置轮询模块中。 http://drupal.org/project/phonepoll
您可能还想看看 VoipDrupal。这允许您直接在 Drupal 中构建与 Tropo 等服务交互的脚本。 http://drupal.org/project/voipdrupal
In Drupal, you cannot run the .module files directly from the web. Each module should implement hook_menu and that hook creates the URLs you'd use. So you'd give Tropo the URL that's created by yourmodule_menu, and not the path to yourmodule.module.
For example, here's a hook_menu from an example module for Tropo.
The demo_menu function defines demo/answer as a URL on your site. If your site was at example.com you'd give Tropo your URL as http://example.com/demo/answer. Then when someone calls your Tropo phone number, the demo_answer() function would run, which speaks "Hello. And Goodbye." and then hangs up.
There's a simple demo module that I've used in a talk on using Drupal as a application framework that might help - I use Tropo extensively in the demo. https://github.com/akalsey/drupal-framework-demo
The Phone poll module would also be a good example. It uses Tropo to add voice and SMS to Drupal 6's built-in poll module. http://drupal.org/project/phonepoll
You might also want to have a look at VoipDrupal. This allows you to build scripts directly in Drupal that interact with services like Tropo. http://drupal.org/project/voipdrupal