Closed (works as designed)
Project:
Services
Version:
6.x-2.2
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
14 Sep 2010 at 02:40 UTC
Updated:
19 Oct 2012 at 12:27 UTC
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
Comment #1
ayb commentedChange 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")
);
Comment #2
tyabut commentedSubscribing.
I banged my head against node.view for 4 days before seeing this.
Comment #3
marcingy commentedClosing as part of tidy up
Comment #3.0
ludo.rUse of PHP tags