【发布时间】:2011-09-20 17:31:10
【问题描述】:
我的博客上有这篇博文:
http://lifepearls.herobo.com/2011/06/tom-hardy-is-bane/
我用我的 php 代码发帖:
function wpPostXMLRPC($title,$body,$rpcurl,$username,$password,$category,$keywords='',$encoding='UTF-8') {
$title = htmlentities($title,ENT_NOQUOTES,$encoding);
$keywords = htmlentities($keywords,ENT_NOQUOTES,$encoding);
$content = array(
'title'=>$title,
'description'=>$body,
'mt_allow_comments'=>0, // 1 to allow comments
'mt_allow_pings'=>0, // 1 to allow trackbacks
'post_type'=>'post',
'mt_keywords'=>$keywords,
'categories'=>array($category)
);
$params = array(0,$username,$password,$content,true);
$request = xmlrpc_encode_request('metaWeblog.newPost',$params);
$ch = curl_init();
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
curl_setopt($ch, CURLOPT_URL, $rpcurl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 1);
$results = curl_exec($ch);
curl_close($ch);
return $results;
}
但是,我不知道如何添加图像,以及添加什么字段。
这是来自仪表板的图片:
http://lifepearls.herobo.com/path.jpg
这是将我的图片添加到帖子中的手动方式,因为它是 特定模板的一部分。
我如何远程添加我的图片,知道吗?
【问题讨论】:
-
如果你有 FTP 访问网站,你可以上传图片,然后使用这个插件自动创建媒体项目。 wordpress.org/extend/plugins/auto-post-images-api。实际上,您可能可以查看简码操作,以了解该插件如何工作以获得更好的想法
标签: php wordpress templates xml-rpc