Php 远程添加WordPress帖子到我的博客,但如何添加图片?
我在我的博客上发表了以下博文: 我使用以下内容从我的php代码发表文章:Php 远程添加WordPress帖子到我的博客,但如何添加图片?,php,wordpress,templates,xml-rpc,Php,Wordpress,Templates,Xml Rpc,我在我的博客上发表了以下博文: 我使用以下内容从我的php代码发表文章: function wpPostXMLRPC($title,$body,$rpcurl,$username,$password,$category,$keywords='',$encoding='UTF-8') { $title = htmlentities($title,ENT_NOQUOTES,$encoding); $keywords = htmlentities($keywords,ENT_NOQU
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;
}
但是,我不知道如何添加图像和哪个字段
以下是来自仪表板的图像:
这是将我的图像添加到帖子的手动方式,因为它是一个
特定模板的一部分
如何远程添加图像,有什么想法吗?无法传输图像或其他资源。你迷路了,除非你通过ftp/sftp传输图像,只需
-包含它们。我们创建了一个插件(),可以将帖子、页面和媒体从一个WordPress安装发送到一个或多个其他WordPress:)它可能就是你正在寻找的内容。如果你有ftp访问该网站的权限,你可以上传图像,然后使用此插件自动创建媒体项。事实上,你也许可以看看短代码的动作,看看插件是如何为更好的想法工作的。Hello,我也有同样的错误