So I read all I could about Drupal Services, I looked in the docs, I searched the group, I found no good info on a external to drupal PHP XML-RPC Client that connects to Drupal Services and interface with the node. Actually I found that the process of auth, node.load, and node.save are very poorly documented. So I am posting my findings.
I will update this as I investigate the search and other services.
Greg
Directions:
In Drupal turn on "Use sessid" - admin/build/services/settings
In your XML-RPC Clinet you will use the following methods: 1-2-3a or 1-2-3b or 1-2-3c
1. system.connect with no args
returns - session id
2. user.login
requires - session id from system.connect
3a. node.load
requires - session id from user.login
requires - nid
requires - array of fields, or empty array
3b. node.save (new node)
requires - session id from user.login
requires - type
requires - uid & name - if you want to associate to a user, otherwise it will be anonymous
optional - any other field you want to specify
3c. node.save (update node)
requires - session id from user.login
requires - type
requires - uid & name - if you want to associate to a user, otherwise it will be anonymous
required - revision - time()
required - created - time()
required - nid
optional - any other field you want to specify
Links:
Docs - http://drupal.org/handbook/modules/services
Group - http://groups.drupal.org/services
PHP XML-RPC Lib - http://phpxmlrpc.sourceforge.net
Here is the sample code to connect, auth, node.load, node.save (new node), & node.save (update node)
Of course you should not run all of this at once.
<?php
include("xmlrpc.inc");
function print_nice
($i){
echo "<pre>";
print_r($i);
echo "</pre>";
}
//connect to the system
//get the session id to use for the user.login
$m = new xmlrpcmsg
('system.connect',
array()
);
$c = new xmlrpc_client
("?q=services/xmlrpc", "localhost", 80);
$c->setDebug(0);
$c->return_type = "phpvals";
$r = &$c->send($m);
if(!$r->faultCode()){
$v=$r->value();
$sessid = ($v['sessid']);
}else{
print "An error occurred on system.connect: ";
}
//login to the system
//use the session id from the system.connect
//get logged in session id for node.load
$m = new xmlrpcmsg
('user.login',
array(
php_xmlrpc_encode
($sessid),
php_xmlrpc_encode
("user1"),
php_xmlrpc_encode
("p4ssw0rd"),
)
);
$c = new xmlrpc_client
("?q=services/xmlrpc", "localhost", 80);
$c->setDebug(0);
$c->return_type = "phpvals";
$r = &$c->send($m);
if(!$r->faultCode()){
$v=$r->value();
$sessid = ($v['sessid']);
$uid = $v['user']['uid'];
}else{
print "An error occurred on user.login: ";
}
// get the info from a node
// use the session id from the user.login
// get node information
$m = new xmlrpcmsg
('node.load',
array(
php_xmlrpc_encode
($sessid), //session from user.login
php_xmlrpc_encode
(10), //nid
php_xmlrpc_encode
(array()), //empty array for all option, array('title') if you want the title
)
);
$c = new xmlrpc_client
("?q=services/xmlrpc", "localhost", 80);
$c->setDebug(0);
$c->return_type = "phpvals";
$r = &$c->send($m);
if(!$r->faultCode()){
$v = $r->value();
print_nice
($v);
}else{
print "An error occurred on node.load: ";
}
//save new node
//use the session id from the user.login
//save new info to a node
$change = array(
"type" => "page", //required
"uid" => 1, //required both uid and name to associate to a user
"name" => "user1", //required both uid and name to associate to a user
"title" => "TEST NODE.SAVE TITLE",
"body" => "this is a body",
);
$m = new xmlrpcmsg
('node.save',
array(
php_xmlrpc_encode
($sessid),
php_xmlrpc_encode
($change)
)
);
$c = new xmlrpc_client
("?q=services/xmlrpc", "localhost", 80);
$c->setDebug(0);
$c->return_type = "phpvals";
$r = &$c->send($m);
if(!$r->faultCode()){
$v = $r->value();
print_nice
($v);
}else{
print "An error occurred on node.save: ";
}
//update a node
//use the session id from the user.login
//send new info to a node
$change = array(
"nid" => 14, //required for update
"revision" => time(), //required for update
"changed" => time(), //required for update
"type" => "page", //required
"uid" => 1, //required both uid and name to associate to a user
"name" => "user1", //required both uid and name to associate to a user
"title" => "TEST NODE.SAVE TITLE **UPDATES**",
"status" => 1, // = published
"body" => "this is a body **UPDATES**",
);
print_nice
($change);
$m = new xmlrpcmsg
('node.save',
array(
php_xmlrpc_encode
($sessid),
php_xmlrpc_encode
($change)
)
);
$c = new xmlrpc_client
("?q=services/xmlrpc", "localhost", 80);
$c->setDebug(0);
$c->return_type = "phpvals";
$r = &$c->send($m);
if(!$r->faultCode()){
$v = $r->value();
print_nice
($v);
}else{
print "An error occurred on node.save: ";
}
?>
Comments
zol
free games | free online
zol
ths a lot ,but the node.load
aaa
qqq
sss
www.salepuma.com
www.ilikebuy.com
www.allofshoes.co.uk
www.360gome.com
tiffany.ilikebuy.com
store.retailnfl.com
shox.ilikebuy.com
puma.360gome.com
edhardy.360gome.com
http://www.ecgohere.com
nike shox
nike dunk sb
puma shoes
coach shoes
re
re
buy 4story Luna
runescape gold
wow gold
fashion jewelry
brea
silver jewelry
ASDASDSAD
nice
yaling
shanshan
Is this D5 or D6?
cqx
cuicui
replica fashion watches wholesale
wow gold
Deduper?
for(;;)If i want to deduplicate and sort a list i think deduper.info is the bomb!www.jerseyfaves.com