artem-frolov/yii-livejournal

Livejournal.com 的 Yii 扩展

v1.0.0 2016-03-12 02:22 UTC

This package is not auto-updated.

Last update: 2024-09-24 00:25:26 UTC


README

使用 ELivejournal 类,您可以在 LiveJournal.com 博客中创建新条目和更新现有条目。

需求

  • Yii 1.0, 1.1 或更高版本
  • 在 PHP 中启用 XML-RPC 支持

使用方法

简单使用

Yii::import('ext.livejournal.*');
$post = new ELivejournal('username', 'password');
$post->subject = 'Subject test';
$post->body = 'Hello, <b>world</b>';
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;
}

高级使用

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;
}

变更日志

yii-livejournal 1.0 (2016年3月12日)

  • 小修复

yii-livejournal 0.3 (2011年12月23日)

  • 修复: 现在扩展与需要 User-Agent 头的最新 API 兼容

yii-livejournal 0.2 (2011年9月9日)

  • 更改: 您不必存储原始 livejournal.com 密码,因为现在 ELivejournal 构造函数可以接受密码的 md5 哈希

yii-livejournal 0.1.1 (2011年8月25日)

  • 小修复

资源