PHP code example of artem-frolov / yii-livejournal
1. Go to this page and download the library: Download artem-frolov/yii-livejournal library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
Yii::import('ext.livejournal.*');
$post = new ELivejournal('username', 'md5_hash_of_the_password', true);
//Use the following line if you want to update an entry by id
//$post->id = 2;
$post->subject = 'Subject test';
$post->body = 'Hello, <b>world</b>';
//Entry's time will be 'now' + 1 week
$post->time = time() + 60*60*24*7;
//Entry's tags will be 'red,green,blue'
$post->tags = array('red','green');
$post->addTag('blue');
//Entry's properties from http://www.livejournal.com/doc/server/ljp.csp.proplist.html
//current music
$post->setMetadata('current_music','Muse - Butterflies and hurricanes');
//Comments will be disabled
$post->setMetadata('opt_nocomments',true);
//Entry will be visible only for friends
$post->setPrivate();
//Turns on \r and \n removing from the entry's body
//Sometimes it's useful because LiveJournal.com translates new lines to <br>
$post->setDeleteNewLines();
if ($post->save())
{
echo "Entry's id: ".$post->id;
echo "<br />Entry's url: ".$post->url;
}
else
{
echo '<b>Error (code '.$post->errorCode.'): </b>';
echo $post->error;
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.