【发布时间】:2011-09-13 22:01:09
【问题描述】:
使用 wordpress 中的插件,我正在尝试通过 tumblr api 传递帖子信息以将其发布到我的 tumblr 博客。
除了我在 tumblr 端收到一个双重帖子之外,一切正常,我不知道为什么。
函数 getImgSrc($postID) { if ( $attachments = get_children( 数组( 'post_type' => '附件', 'post_mime_type' => 数组('图像'), 'numberposts' => 1, 'post_status' => 空, 'post_parent' => $post->ID ))); foreach ($attachments 作为 $attachment) { $t_source = wp_get_attachment_url($attachment->ID); } 返回$t_source; } //将博客发布到tumblr 函数 postBlogTumblr($postID) { $URLServer = "http://www.tumblr.com/api/write"; $t_post = get_post($postID); $tumblr_data = unserialize(get_option("tumblr")); $postdata['email'] = $tumblr_data['tumblr_login_email']; $postdata['password'] = $tumblr_data['tumblr_login_pass']; $postdata['type'] = "照片"; $postdata['source'] = getImgSrc($postID); $postdata['caption'] = $t_post->post_title; $postdata['state'] = "已发布"; $postdata = http_build_query($postdata); $result = datapost($URLServer,$postdata); } 函数 postBlogTumblr($postID) { $URLServer = "http://www.tumblr.com/api/write"; $t_post = get_post($postID); $tumblr_data = unserialize(get_option("tumblr")); $postdata['email'] = $tumblr_data['tumblr_login_email']; $postdata['password'] = $tumblr_data['tumblr_login_pass']; $postdata['type'] = "常规"; $postdata['title'] = $t_post->post_title; $postdata['body'] = $t_post->post_content; $postdata['state'] = "已发布"; $postdata = http_build_query($postdata); $result = datapost($URLServer,$postdata); }任何指导将不胜感激。
【问题讨论】:
-
wordpress 有专门的网站,可以看看 wordpress.stackexchange.com
-
您如何以及在哪里致电
postBlogTumblr()?
标签: php wordpress api curl tumblr