在wordpress中使用插件,我试图通过tumblr api传递帖子信息,并将其发布到我的tumblr博客。
除了我在tumblr端有一个双重帖子的事实之外,一切都有效,我不知道为什么。
function getImgSrc($postID) { if ( $attachments = get_children( array( 'post_type' => 'attachment', 'post_mime_type' => array('image'), 'numberposts' => 1, 'post_status' => null, 'post_parent' => $post->ID ))); foreach ($attachments as $attachment) { $t_source = wp_get_attachment_url( $attachment->ID ); } return $t_source; } //post blog to tumblr function 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'] = "photo"; $postdata['source'] = getImgSrc($postID); $postdata['caption'] = $t_post->post_title; $postdata['state'] = "published"; $postdata = http_build_query($postdata); $result = datapost($URLServer,$postdata); } function 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'] = "regular"; $postdata['title'] = $t_post->post_title; $postdata['body'] = $t_post->post_content; $postdata['state'] = "published"; $postdata = http_build_query($postdata); $result = datapost($URLServer,$postdata); }
非常感谢任何指导。
答案 0 :(得分:0)
根据您发布的代码,我只能怀疑您收到双重帖子,因为您复制了postBlogTumblr()
功能。