【问题标题】:Add remotely WordPress Posts to my blog, but how to add picture?远程添加 WordPress 帖子到我的博客,但是如何添加图片?
【发布时间】: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


【解决方案1】:

我们创建了一个插件 (WP Remote Connections),它可以将帖子、页面和媒体从一个 WordPress 安装发送到一个或多个其他 WordPress :) 这可能是您正在寻找的。​​p>

【讨论】:

【解决方案2】:

MetaWebLog API 无法传输图像或其他资源。你迷路了,除了你通过 ftp/sftp 传输图像并且只是<img>-包括它们。

【讨论】:

    猜你喜欢
    • 2014-06-02
    • 1970-01-01
    • 1970-01-01
    • 2018-11-17
    • 1970-01-01
    • 2011-11-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多