**[[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]]



トップ   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS