- 追加された行はこの色です。
- 削除された行はこの色です。
**[[PHP/XML-RPC/metaWeblog.newPostによる投稿]] [#jded7a59]
jugemの場合
>
function metaWeblog_newPost($t,$d){
$user = "ユーザ名";
$host = "ブログ名.jugem.jp";
$xmlrpc_passwd = "パスワード";
$xmlrpc_path = "/admin/xmlrpc.php/";
$port = 80;
///////////////////////////////////////////////
//PearのXMLRPCパッケージを読み込む
require_once("RPC.php");
//XMLRPC文字コードを設定
$GLOBALS['XML_RPC_defencoding'] = "UTF-8";
//XMLRPCクライアントの作成
$Client = new XML_RPC_client( $xmlrpc_path, $host, $port );
$appkey = new XML_RPC_Value( '', 'string' );
$blogid = new XML_RPC_Value( '0', 'string');
//ユーザ名作成
$username = new XML_RPC_Value( $user, 'string' );
//パスワード作成
$passwd = new XML_RPC_Value( $xmlrpc_passwd, 'string' );
//コンテンツ作成
$content = new XML_RPC_Value(array(
'title'=> new XML_RPC_Value($t, 'string'),
'description'=> new XML_RPC_Value($d, 'string'),
'dateCreated'=> new XML_RPC_Value(date("Ymd\TH:i:s",time()), 'dateTime.iso8601')
), 'struct');
//パブリッシュのフラグ作成
$publish = new XML_RPC_Value( 1, 'boolean');
//XML-RPCメソッドのセット
$Message = new XML_RPC_Message(
'metaWeblog.newPost',
array($blogid, $username, $passwd, $content, $publish) );
//echo htmlentities($Message->serialize());
//print_r($Message);
//メッセージ送信
$Client->setDebug(1);
$res = $Client->send($Message);
print_r( $res);
}
[[PHP/XML-RPC]]