我正在使用已安装的WebForm模块的Drupal 6。

我需要能够远程发布,从PHP结果到WebForm。伪代码:

<?php
//File: remote_script_not_hosted_on_the_same_server_as_drupal.php

$results = array(
'name' => 'testname',
'age' => '6',
);

$node = 5;

$url_to_drupal = 'http://remote_server.com/drupal-6.2';

insert_into_webform($results, $node, $url_to_drupal);

当然,这个示例并不完美,但是您(希望)明白了这个主意。

您将如何做到这一点?

我已经在Drupal队列上开了一个问题: http://drupal.org/node/1082016

我担心这两个字段使我的远程提交无效:

------WebKitFormBoundaryKIiNRZCPZIFlYWKc
Content-Disposition: form-data; name="form_build_id"

form-58f36748bfffd6752f204eadf1ba87c9
------WebKitFormBoundaryKIiNRZCPZIFlYWKc
Content-Disposition: form-data; name="form_token"

e4becb726ea858b6914980b9142b7f30
有帮助吗?

解决方案

我没有尝试过,但是 专业开发 (我有第二版)是指使用 XML-RPC 去做这个。它使用标准安装的一部分来完成其工作的页面XMLRPC.PHP。

其他提示

您是否尝试过使用PHP手动发送帖子数据?这是来自 http://www.webmasterworld.com/php/3164561.htm

$server= 'www.someserver.com';
$url = '/path/to/webform/posturl';
$content = 'name1=value1&name2=value2';
$content_length = strlen($content);
$headers= "POST $url HTTP/1.0\r\nContent-type: text/html\r\nHost: $server\r\nContent-length: $content_length\r\n\r\n";
$fp = fsockopen($server, $port, $errno, $errstr);
if (!$fp) {
    return false;
}
fputs($fp, $headers);
fputs($fp, $content);
$ret = "";
while (!feof($fp)) {
    $ret .= fgets($fp, 1024);
}
fclose($fp);
print $ret;

当然,如果您在表单上使用任何形式的验证码,这将失败,并且如果需要对您进行身份验证以发布依据,目前也将失败

许可以下: CC-BY-SA归因
scroll top