[eluser]GIN[/eluser]
Code:
class LiveJournal extends Controller {
private $LJ_url = 'http://www.livejournal.com/interface/xmlrpc';
private $LJ_login = 'your login';
private $LJ_pass = 'your pass';
function LiveJournal()
{
parent::Controller();
$this->load->library('xmlrpc');
}
function index()
{
$this->xmlrpc->server($this->LJ_url);
$this->xmlrpc->method('LJ.XMLRPC.getchallenge');
if (!$this->xmlrpc->send_request()) {
echo $this->xmlrpc->display_error();
}
else {
$challenge_response = $this->xmlrpc->display_response();
$request = array(
array(
array(
'username'=>array($this->LJ_login,'string')
,'auth_method'=>array('challenge','string')
,'auth_challenge'=>array($challenge_response['challenge'],'string')
,'auth_response'=>array(md5($challenge_response['challenge'].md5($this->LJ_pass)),'string')
,'ver'=>array(2,'int')
,'event'=>array('Post text','string')
,'subject'=>array('Post subject','string')
,'year'=>array(2009,'int')
,'mon'=>array(11,'int')
,'day'=>array(12,'int')
,'hour'=>array(5,'int')
,'min'=>array(27,'int')
,'props'=>array(
array(
'opt_backdated'=>array(true,'boolean')
,'taglist'=>array('tag 1, tag 2, tag 3','string')
)
,'struct')
,'security'=>array('public','string')
)
,'struct'
)
);
$this->xmlrpc->method('LJ.XMLRPC.postevent');
$this->xmlrpc->request($request);
if (!$this->xmlrpc->send_request()) {
echo $this->xmlrpc->display_error();
}
else {
$postData = $this->xmlrpc->display_response();
//$postData['url'] – here url of your post
}
}
}
}
Thanks to Vladimir who [url="http://www.simplecoding.org/xml-rpc-codeigniter-livejournal-i-kucha-problem.html"]solved[/url] this problem.
First of all - be careful when prepare array for posting!
And also I've got problems with posting on localhost with russian texts only, but on hosted server it works awesome.