You say in your email "All methods on the server require that you give
your user login and password (MD5 encoded) as strings in the first two
parameters."

You don't seem to be doing that.  Your error message is generated
because you are giving the wrong number of parameters.

Replace: $f=new xmlrpcmsg('hpe.getSource', array('search term removed'));

With: $f=new xmlrpcmsg('hpe.getSource', new xmlrpcval($login), new
xmlrpcval($password), new xmlrpcval("18", 'int')));


The method 'getSource' can not search the newsisfree.com on a specific
string, you must specify the source ID you want.  In this case, 18 is
used.  If you want to grab news from more than one source, the third
parameter can be an array of source IDs.  Ex.:  array(new
xmlrpcval("18", 'int'),new xmlrpcval("19", 'int')).

See this: http://www.newsisfree.com/apixmlrpc.php?hpe=getSource#doc


[EMAIL PROTECTED] wrote:
> I'm a newbie who doesn't know anything about php coding or xml-rpc, but trying
> to implement news syndication on my site using Newsisfree, using XMLRPC-2.1. 
> I'm completely lost regarding the "Incorrect parameters passed to method:
> Wanted , got  at param" error message I've been getting.
> 
> First, some background information:
> 
> I want to seach Newsisfree and compile a list of news items relating to the
> search word or phrase in xml format, then for my visitors to subscribe to it. 
>  
> 
> Here are some of the specifications from Newisfree:
> 
> Configure your XML-RPC client using the information below. All methods on the
> server require that you give your user login and password (MD5 encoded) as
> strings in the first two parameters. 
> At this time, there are three methods configured on the server (see samples
> below):
> hpe.getSource : retrieve the meta data AND list of news items for a given
> source. To find an ID for a source, use the source browsing page. 
> hpe.getSourceInfo : retrieve the meta data for a given source. 
> hpe.getSourceItems : retrieve the list of news items for a given source. 
> hpe.getSources : retrieve the list of news items for a several sources. 
> hpe.searchSources : search for sources which contain a string in their name. 
> hpe.createUser : creates a new user. 
> 
> And the code I'm using so far is:
> 
> <?php
>   include("xmlrpc.inc");
> 
>   $c=new xmlrpc_client("/RPC", "www.newsisfree.com", 80);
>   $c->setCredentials("username removed", "password removed");
>   $f=new xmlrpcmsg('hpe.getSource', array('search term removed'));
>   $c->setDebug(2);
>   $r=$c->send($f);
>   if (!$r->faultCode()) {
>     $v=$r->value();
>     print "I received:" . htmlspecialchars($v->scalarval()) . "<br/>";
>     print "<hr/>I got this value back<br/>pre>" .
>       htmlentities($r->serialize()). "</pre>\n";
>   } else {
>     print "An error occurred: ";
>     print "Code: " . htmlspecialchars($r->faultCode()) .
>       " Reason: '" . ($r->faultString()) . "'<br/>";
>   }
> /*** client side ***/
> // $c = new xmlrpc_client('http://www.newsisfree.com/RPC');
> 
> // tell the client to return raw xml as response value
> $c->return_type = 'xml';
> 
> if ($r->faultCode())
>   // HTTP transport error
>   echo 'Got error '.$r->faultCode();
> else
> {
>   // HTTP request OK, but XML returned from server not parsed yet
>   $v = xmlrpc_decode($r->value());
>   // check if we got a valid xmlrpc response from server
>   if ($v === NULL)
>     echo 'Got invalid response';
>   else
>   // check if server sent a fault response
>   if (xmlrpc_is_fault($v))
>     echo 'Got xmlrpc fault '.$v['faultCode'];
>   else
>     echo'Got response: '.htmlentities($v);
> }
>   
> ?>
> </body>
> </html>
> 
> Here is what is happening:
> 
> ---SENDING---
> POST /RPC HTTP/1.0
> User-Agent: XML-RPC for PHP 2.1
> Host: www.newsisfree.com:80
> Authorization: Basic removed 
> Accept-Encoding: gzip, deflate
> Accept-Charset: UTF-8,ISO-8859-1,US-ASCII
> Content-Type: text/xml
> Content-Length: 106
> 
> <?xml version="1.0"?>
> <methodCall>
> <methodName>hpe.getSource</methodName>
> <params>
> </params>
> </methodCall>
> ---END---
> 
> ---GOT---
> HTTP/1.1 200 OK
> Date: Sun, 04 Feb 2007 19:42:07 GMT
> Server: Apache/1.3.33 (Unix) mod_gzip/1.3.26.1a PHP/4.3.9 mod_ssl/2.8.22
> OpenSSL/0.9.7e
> X-Powered-By: PHP/4.3.9
> Connection: close
> Content-Type: text/xml
> Content-length: 388
> 
> <?xml version="1.0" ?>
> <methodResponse>
> <fault>
>   <value>
>     <struct>
>       <member>
>         <name>faultCode</name>
>         <value><int>3</int></value>
>       </member>
>       <member>
>         <name>faultString</name>
>         <value><string>Incorrect parameters passed to method: Wanted , got  at
> param )</string></value>
>       </member>
>     </struct>
>   </value>
> </fault>
> </methodResponse>
> ---END---
> 
> HEADER: date: Sun, 04 Feb 2007 19:42:07 GMT
> HEADER: server: Apache/1.3.33 (Unix) mod_gzip/1.3.26.1a PHP/4.3.9
> mod_ssl/2.8.22 OpenSSL/0.9.7e
> HEADER: x-powered-by: PHP/4.3.9
> HEADER: connection: close
> HEADER: content-type: text/xml
> HEADER: content-length: 388
> 
> ---PARSED---
> class xmlrpcval {
>   var $me = 
>   array (
>     'struct' => 
>     array (
>       'faultCode' => 
>       class xmlrpcval {
>         var $me = 
>         array (
>           'int' => 3,
>         );
>         var $mytype = 1;
>         var $_php_class = NULL;
>       },
>       'faultString' => 
>       class xmlrpcval {
>         var $me = 
>         array (
>           'string' => 'Incorrect parameters passed to method: Wanted , got  at
> param )',
>         );
>         var $mytype = 1;
>         var $_php_class = NULL;
>       },
>     ),
>   );
>   var $mytype = 3;
>   var $_php_class = NULL;
> }
> ---END---
> An error occurred: Code: 3 Reason: 'Incorrect parameters passed to method:
> Wanted , got at param )'
> Got error 3 
> 
> I know this is a lengthy email, but I wanted to answer as much question 
> upfront
> as possible.  I hope someone here can help me get this thing implemented. 
> 
> Thank you.
> 
> 
> _______________________________________________
> phpxmlrpc mailing list
> phpxmlrpc@lists.usefulinc.com
> http://lists.usefulinc.com/cgi-bin/mailman/listinfo/phpxmlrpc

-- 

 Kyle Wilcox
 NOAA Chesapeake Bay Office
 410 Severn Avenue
 Suite 107A
 Annapolis, MD 21403
 office: (410) 295-3151
 [EMAIL PROTECTED]



_______________________________________________
phpxmlrpc mailing list
phpxmlrpc@lists.usefulinc.com
http://lists.usefulinc.com/cgi-bin/mailman/listinfo/phpxmlrpc

Reply via email to