문제

I'm using drupal 6 with the webform module installed.

I need to be able to remotely POST, from PHP results to a webform. Pseudocode:

<?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);

Of course, this example isn't perfect, but you (hopefully) get the idea.

How would you go about doing this?

I've opened an issue on the drupal queue: http://drupal.org/node/1082016

I'm concerned about these two fields invalidating my remote submission:

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

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

e4becb726ea858b6914980b9142b7f30
도움이 되었습니까?

해결책

I've not tried it, but chapter 19 of Pro Drupal Development (I have the 2nd edition) refers to using xml-rpc to do this. It uses the page xmlrpc.php that's part of the standard install to do its work.

다른 팁

Have you tried using PHP to manually send the POST data? Here is a snippet from 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;

Of course this would fail if you are using any form of captcha on the form, and will also currently fail if you are required to be authenticated to post a reponse

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 drupal.stackexchange
scroll top