WEBサービス・API/FC2/XML-RPC

1月 1, 2003 · Posted in FC2, WEBサービス・API · Comment 

XML-RPC

PHPのコード

<?php
require_once "XML/RPC.php";

//XML-RPCインタフェース、ユーザ定義
$fc2User = "ユーザーID";
$fc2Password = "パスワード";

$title = "記事の件名";
$content = "記事の本文";

$GLOBALS["XML_RPC_defencoding"] = "UTF-8";

$message = new XML_RPC_Message("metaWeblog.newPost", array(
new XML_RPC_Value(0, "string"),
new XML_RPC_Value($fc2User, "string"),
new XML_RPC_Value($fc2Password, "string"),
new XML_RPC_Value(array(
"title"=> new XML_RPC_Value($title, "string"),
"description"=> new XML_RPC_Value($content, "string"),
"dateCreated"=> new XML_RPC_Value(date("Ymd\TH:i:s", time()), "dateTime.iso8601")
), "struct"),
new XML_RPC_Value(1, "boolean"),
));

$client = new XML_RPC_client("/xmlrpc.php", "blog.fc2.com", 80);
$response = $client->send($message);
?>