ホーム > mixi | plugin | wordpress > wordpress2mixi

wordpress2mixi

mixiが新着日記とかの情報をrssで配信しているので適当にPlaggerのPluginでも書こうと思っていたけど、調べていたらどうもiPhone向けに日記投稿APIも用意されているみたい。それだけじゃなくPEARのパッケージも用意されているみたい。

これ使えばWp-MixiPublisherよりもスマートに日記を投稿できるんじゃないかと思って適当に書いてみた。

ちなみにWordPressのPluginを書くのは初めてなので汚くても許してください><

<?php
/*
Plugin Name: wordpress2mixi
Plugin URI: http://modern-magic.net/blog/
Description: WordPressの投稿をmixiにも同時投稿するプラグイン
Author: fuyumacha
Version: 0.1
Author URI: http://modern-magic.net/blog/
*/
require_once ‘Services/MixiAPI/Diary.php’;
require_once ‘Services/MixiAPI/Image.php’;
require_once ‘Services/MixiAPI/Factory.php’;
function wordpress2mixi($postId){
$mixi_user = ‘hogehogehoge’;
$mixi_pass = ‘hogehogehoge’;
$mixi_id = ’0123456789′;
$mixi_post = get_post($postId);
$mixi_title = $mixi_post->post_title;
$mixi_content = $mixi_post->post_content;
if($mixi_post->post_status != ‘publish’){
return $postId;
}
$diary = new Services_MixiAPI_Diary($mixi_title, $mixi_content);
$service = Services_MixiAPI_Factory::getInstance(
Services_MixiAPI_Factory::API_MODE_POSTDIARY,
$mixi_user, $mixi_pass, $mixi_id);
$service->setDiary($diary);
$service->execute();
return $postId;
}

add_action(‘publish_post’,'wordpress2mixi’);
?>

こんな感じでとりあえず動いている。

もちろんServices_MixiAPIが必要なので適宜インストールしておく。

# pear install -af http://www.doyouphp.jp/pear/Services_MixiAPI-0.2.0.tgz

ちなみにボクはなんかエラーがはかれてインストールできなかったので適当に突っ込んだ。

まぁ動いているからいいんじゃないかなー。

管理画面とかその他諸々は明日やる・・・かも。

コメント:1

fuyumacha 2008 年 9 月 14 日

課題は管理画面と二重投稿対策ですねー
まぁ適当に書けそうな感じ。

コメントフォーム
入力した情報を記憶する

トラックバック:0

この記事のトラックバック URL
http://modern-magic.net/blog/2008/09/wordpress2mixi/trackback/
トラックバックの送信元リスト
wordpress2mixi - modern-magic.net より

ホーム > mixi | plugin | wordpress > wordpress2mixi

検索
フィード
メタ情報

ページの上部に戻る