[phpxmlrpc] Using PHPXMLRPC with TopicExchange

a.h.s. boy (lists) spudlists at nothingness.org
Mon Mar 19 01:05:44 UTC 2007


Saqib --

As you can clearly see from your $params, you are sending 4 "string"  
variables as your parameters, when their API requests 1 string and 1  
struct. ("topicName" and "details").

You're not even sending them "topicName" (the "channel" your content  
should appear on), so that's the first problem. Your setup should  
look more like this:

// make a string value for topicName
$topicName = new xmlrpcval("Some Topic Name","string");
// make a struct value for details
// creating a struct in PHPXMLRPC is just like building an  
associative array in PHP but all the values have to be xmlrpcvals
$details = new xmlrpcval(
   array(
     "blog_name" => new xmlrpcval("Blog Name", "string"),
     "title" => new xmlrpcval("Post Title", "string"),
     "url" => new xmlrpcval("http://www.example.com/","string"),
     "excerpt" => new xmlrpcval("foo foo foo...","string")
   ),
   "struct");

...etc...

$params = array($topicName,$details);
$message = new xmlrpcmsg($xml_rpc_method, $params);

...and that should do the trick. I must admit, though, I'm a little  
confused as to why the error says their API "takes exactly 3  
arguments (5 given)" when it takes _2_, and you sent _4_. Sounds like  
they're counting wrong over there...

spud.


On Mar 16, 2007, at 11:30 PM, Saqib wrote:

> TopicExchange.com seems to use a slightly different XML-RPC  
> interface (documented at http://topicexchange.com/doc/xmlrpc). How  
> would I use PHPXMLRPC to create a message that topicexchange would  
> accept?
>
> topicexchange says it wants a message of the form struct  
> topicExchange.ping(string topicName, struct details), where struct  
> details contains 4 (optional 5) items:
> - string blog_name
> - string title
> - string url
> - string excerpt
> - boolean autoMunge (optional)
>
> I'm trying the following:
> <?php
> $name_param = new xmlrpcval('Blog Name', 'string');
> $title_param = new xmlrpcval('Post Title', 'string');
> $url_param = new xmlrpcval('http://www.domain.com/post_url',  
> 'string');
> $excerpt_param = new xmlrpcval('Some excerpt text', 'string');
> $params = array($name_param, $title_param, $url_param,  
> $excerpt_param);
>
> $xml_rpc_method = "topicExchange.ping";
> $service_url = "http://topicexchange.com/RPC2";
> $parse_url = parse_url($service_url);
> $xml_rpc_server = $parse_url['host'];
> $xml_rpc_port = $parse_url['port'];
> if($xml_rpc_port=='') $xml_rpc_port = 80;
> $xml_rpc_path = $parse_url['path'];
>
> $message = new xmlrpcmsg($xml_rpc_method, $params);
> $client = new xmlrpc_client($xml_rpc_path, $xml_rpc_server,  
> $xml_rpc_port);
> $client->debug = 2;
> $response = $client->send($message);
> ?>
>
> This doesn't work; I get back: "TypeError: topicExchange_ping()  
> takes exactly 3 arguments (5 given)"
>
> What would be the proper way to structure the message so that this  
> XML-RPC interface of topicExchange.ping(string topicName, struct  
> details) understands it?
>
> Thanks,
> Saqib
> _______________________________________________
> phpxmlrpc mailing list
> phpxmlrpc at lists.usefulinc.com
> http://lists.usefulinc.com/cgi-bin/mailman/listinfo/phpxmlrpc

-------------------------------------------------------------------
a.h.s. boy
spud(at)nothingness.org            "as yes is to if,love is to yes"
http://www.nothingness.org/
-------------------------------------------------------------------



More information about the phpxmlrpc mailing list