📜 ⬆️ ⬇️

Connecting the blog and Livejournal via XML-RPC

The XML remote procedure call is actually a very simple procedure, with the help of which I can now write on my blog and copy the article in livejournal. In appearance, the simplest solution would probably be the creation of such a process, where the transfer of data to the LJ server would occur by the browser. It is enough to create a separate iframe, put a form into it, into which to copy content from another form and eventually publish it to LJ. But - firstly it’s ugly, secondly it’s not a fact that you can fake it. It’s much easier and more convenient to transfer all data through xml-rpc. To do this, install the finished library and use the function ..

function post2livejournal($subject,$event,$time=0) {
require_once('lib/xmlrpc.inc');
$lj_userid='my_livejournal_username';
$lj_passwd='my_secret_password';

if (!$time)$time=time();
$year=date('Y',$time);
$month=date('m',$time);
$day=date('d',$time);
$hour=date('H',$time);
$minute=date('i',$time);

$client=new xmlrpc_client("/interface/xmlrpc", "www.livejournal.com", 80);

$params = new xmlrpcval( array(
'username' => new xmlrpcval($lj_userid,'string'),
'password' => new xmlrpcval($lj_passwd,'string'),
'ver' => new xmlrpcval('1','string'),
'lineendings' => new xmlrpcval('pc','string'),
'event' => new xmlrpcval($event,'string'),
'subject' => new xmlrpcval($subject,'string'),
'year' => new xmlrpcval($year,'int'),
'mon' => new xmlrpcval($month,'int'),
'day' => new xmlrpcval($day,'int'),
'hour' => new xmlrpcval($hour,'int'),
'min' => new xmlrpcval($minute,'int')),'struct'
);

$msg = new xmlrpcmsg('LJ.XMLRPC.postevent');
$msg->addparam($params);
$client->setDebug(0);
$result = $client->send($msg);
}



And that would not have appeared type errors
Application failed during request deserialization Check the encoding in the library - for sure utf tries to send as iso.

')
... so why is there no XML-RPC on habrahabr?

Source: https://habr.com/ru/post/12217/


All Articles