我試圖從非drupal站點創建一個drupal站點中的節點,但我無法讓我的生活得到它的工作。如何從非drupal站點使用drupal服務node.save?
這是我從谷歌上搜索周圍構造的代碼...
$domain = 'http://mydomain.com';
$operation = 'node.save';
$api_key = 'my api key';
$timestamp = (string) time();
$nonce = substr(md5(uniqid('s', true)), 0, 10);
$hash = hash_hmac('sha256', $timestamp .';'.$domain .';'. $nonce .';'.$operation, $api_key);
$node_data = array(
'type' => 'story',
'title' => 'test story title',
'body' => 'test story text'
);
$send_data = array(
'method' => $operation,
'args' => array(
'hash' => $hash,
'domain_name' => $domain,
'domain_time_stamp' => $timestamp,
'nonce' => $nonce,
'node' => serialize($node_data)
)
);
$request = xmlrpc_encode_request($operation, $send_data);
$context = stream_context_create(
array(
'http' => array(
'method' => "POST",
'header' => "Content-Type: text/xml",
'content' => $request
)
)
);
$retrieve = file_get_contents($domain .'/services/xmlrpc', false, $context);
$response = xmlrpc_decode($retrieve);
echo '<pre>'. htmlspecialchars(print_r($response, 1)) .'</pre>';
但承滴盤我從服務器返回的是:「缺少必需參數:節點」,而我是一個該死的是傳遞狗屎通過....
我可以得到一個「system.connect」的迴應,這讓我感覺很好,但那就是我所能得到的。我的服務設置不需要session_id。
幫助我的StackOverflow ......你是我唯一的希望