1

我想构建一个流程,当在 Drupal 中创建节点(一篇文章)时,节点的标题作为消息发布到 Facebook。将消息发布到 Facebook 没有问题,但我不知道如何获得在 Drupal 安装中创建新内容的事件。有什么建议么?

4

2 回答 2

1

从 Drupal 方面,您可以编写一个简单的自定义模块并实现hook_node_insert(),例如

function MYMODULE_node_insert($node) {
  if ($node->type == 'article') {
    push_article($node->title);
  }
}
于 2013-08-16T17:00:00.490 回答
1

From a pure Mule point of view with no changes to Drupal you could poll the index-nodes operation of the Drupal connector http://mulesoft.github.io/drupal-connector/mule/drupal-config.html#index-nodes

<poll frequency="60000">
    <drupal:index-nodes startPage="1" pagesize="10">
        <drupal:fields>
            <drupal:field>nid</drupal:field>
            <drupal:field>type</drupal:field>
            <drupal:field>title</drupal:field>
        </drupal:fields>
    </drupal:index-nodes>
</poll>

You would then have to somehow persist a marker such as the last modified date or the last page number in a persistent object-store so it can be read on the next poll so you know which nodes have been processed or which page to start from. If you're using Mule 3.5... then there's a new "watermark" feature for that specific type of functionality. A bit of info on watermarks here: https://www.mulesoft.org/jira/browse/MULE-6861

However a better solution to polling would be to use a message queue such as ActiveMQ or RabbitMQ that Drupal could publish a message to via Stomp for example and Mule can pick up it up via a JMS inbound endpoint or an AMQP inbound endpoint - dependant on what messaging you go with. This way messages are pushed rather than pulled, but does require Drupal customisation.

于 2013-08-16T16:26:40.887 回答