I am trying to write a code to access the node (10) either through node.get or node.view on a drupal website which has service module enabled but the debugger said I am Missing required arguments. I know it has something to do with my '$key' and '$m'. The following is my code. Thanks for any help in advance.

include("xmlrpc300beta/lib/xmlrpc.inc");

$domain = 'sample.com';
$apiKey = '55f7eaxxx00758c8a92xxxb9121abc36';
$endPoint = 'http://www.sample.com/services/xmlrpc';
$methodName = "node.view";
$timestamp = (string)time();
$code = md5(uniqid(rand(), true));
$nonce = substr($code, 0, 20);
$hash = hash_hmac('sha256', $timestamp .';'.$domain .';'. $nonce .';'. $methodName, $api_key);

$c = new xmlrpc_client($endPoint);

$c->setDebug(1);

$key = new xmlrpcval(
array(
"hash" => new xmlrpcval($hash, "string"),
"method" => new xmlrpcval($methodName, "string"),
"domain_name" => new xmlrpcval($domain, "string"),
"domain_time_stamp" => new xmlrpcval($timestamp, "string"),
"nonce" => new xmlrpcval($nonce, "string"),
"api_key" => new xmlrpcval($apiKey, "string"),
"nid" => new xmlrpcval(10, "int")
), "struct");

$m = new xmlrpcmsg($methodName,$key);

$c->return_type = 'phpvals';
$r = $c->send($m);

var_dump($r->value());

Comments

ayb’s picture

Change the original $key to the following and $methodName = 'node.get' and it works.
But somehow it is not working when $methodName = 'node.view' which take the same required arguments as node.get.

$key =
array(
new xmlrpcval($hash, "string"),
new xmlrpcval($domain_name, "string"),
new xmlrpcval($domain_time_stamp, "string"),
new xmlrpcval($nonce, "string"),
new xmlrpcval(10, "int")
);

tyabut’s picture

Subscribing.

I banged my head against node.view for 4 days before seeing this.

marcingy’s picture

Status: Active » Closed (works as designed)

Closing as part of tidy up

ludo.r’s picture

Issue summary: View changes

Use of PHP tags