Welcome Guest, Not a member yet? Register   Sign In
XML-RPC & Digg API
#1

[eluser]bagwaa[/eluser]
I have been playing around with the digg api and xml-rpc calls from inside CI, however I am having a few problems, I am pretty sure this is just down to the fact that I am pretty new to ths digg api AND xml-rpc, so the chance of me doing something idiotic at the moment is quite high.

Anyway, I have created a basic controller, and all I want to be able todo is make an XML-RPC call to the digg api and pull back some very basic information that I can then disect.

As I understand it I have to supply a few things and then just make the call, here is my first attempt at my controller...

class Dashboard extends controller {
function Dashboard() {
parent::Controller();
$this->load->library('xmlrpc');
}

function myCall() {
$url = 'http://services.digg.com/stories/topic/programming?appkey=http://my.domain.com';
$this->xmlrpc->set_debug(TRUE);
$this->xmlrpc->server($url, 80);
$this->xmlrpc->method('/stories/topic/programming');

if ( ! $this->xmlrpc->send_request()) {
echo $this->xmlrpc->display_error();
}
}
}

I am getting back the data in the debug information, but the error that I am getting is :-

---Invalid Return--- Top level XML-RPC element is missing---Invalid Return--- The XML data receieved was either invalid or not in the correct form for XML-RPC. Turn on debugging to examine the XML data further. Top level XML-RPC element is missing

Am I on the right track here? it feels like im off-track here but with the CI wiki and the digg api wiki I can't put the two together, any pointers would be appreciated :-)
#2

[eluser]Pascal Kriete[/eluser]
Just a quick look at the api documentation makes me question the whole approach. At the very beginning it states that it's a Rest API. Not xml-rpc.

Now I know there's a lot of confusion about REST vs SOAP vs XML-RPC, and you can argue about which is best till you're blue in the mouth and tears are shed. What it boils down to in this case is that you make a request almost like you're browsing the web, and it will return the data in any format you want. It supports all kinds of response types. So you don't even have to deal with XML if you don't want to.

If you go to the bottom of the response types page there is an example on how to use the API from within PHP, and it returns .. wait for it .. serialized PHP.
Serialized PHP!! What more could you want.

ps. If you do get XML from an api, just tossing it at simpleXML gets you an easy to use object.




Theme © iAndrew 2016 - Forum software by © MyBB