火车采集器软件交流官方论坛

 找回密码
 加入会员
搜索
火车采集器V9版免费下载火车浏览器 - 可视采集,万能群发,全自动脚本工具
查看: 6128|回复: 1

wp的免登陆发布接口怎么制作有教程吗?

[复制链接]
发表于 2018-1-22 22:47:56 | 显示全部楼层 |阅读模式
本帖最后由 妞給爺_WogSO 于 2018-1-22 22:59 编辑

发布模块和采集规则已经做好可以用的下载过来的免费登陆发布接口测试采集只能才采集到标题和内容   
用的wp模板是修改的可能一般的免登陆发布接口不能识别发布参数的另外几项目我有修改添加到接口里面去了还是没有用
我的发布参数是   
post_title = [标签:内容]
post_category = [分类classid]
post_wpmby_buy_link = [标签:链接]
post_wpmby_price = [标签:价格]

下面是免登陆发布接口大神帮忙看下哪里错误

<?php
*/
//-------------------配置参数开始,根据需要修改-------------------------
$post_author_default    = 1;      
$post_status    = "publish";
$time_interval  = 1;        
$post_next      = "now";
$post_ping      = false;   
$translate_slug = false;
$secretWord     = false;
//-------------------配置参数结束,以下请勿修改-------------------------
if(isset($_GET['action'])){
    $hm_action=$_GET['action'];
}
else{
    die ("操作被禁止>");
}
$post=$_POST;
include "./wp-config.php";
if ( get_magic_quotes_gpc() ) {
$post = array_map('stripslashes_deep', $_POST );
}
if($post_ping) require_once("./wp-includes/comment.php");
if( !class_exists("Snoopy") ) require_once ("./wp-includes/class-snoopy.php");
function hm_debug_info($msg)
{
    global $logDebugInfo;
    if($logDebugInfo) echo $msg."<br/>\n";
}
function hm_tranlate($text){
$snoopy = new Snoopy;
$url = "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=".urlencode($text)."&langpair=zh-CN%7Cen";
$submit_vars["text"] = $text;
$submit_vars["ie"] = "UTF8";
$submit_vars["hl"] = "zh-CN";
$submit_vars["langpair"] = "zh|en";
$snoopy->submit($url,$submit_vars);
$htmlret = $snoopy->results;
$htmlret = explode('translatedText',$htmlret);
$htmlret = explode('}',$htmlret[1]);
$htmlret = $htmlret[0];
$htmlret = str_replace('"','',$htmlret);
$htmlret = str_replace(':','',$htmlret);
return $htmlret;
}
function hm_print_catogary_list()
{
    $cats = get_categories("hierarchical=0&hide_empty=0");
foreach ((array) $cats as $cat) {
        echo '<<<'.$cat->cat_ID.'--'.$cat->cat_name.'>>>';
}
}
function hm_get_post_time($post_next="normal")
{
    global $time_interval;
    global $wpdb;
    $time_difference = absint(get_option('gmt_offset')) * 3600;
    $tm_now = time()+$time_difference;
   
    if ($post_next=='now'){
        $tm=time()+$time_difference;
    }
    else //if ($post_next=='next')
    {
        $tm = time()+$time_difference;
       $posts = $wpdb->get_results( "SELECT post_date FROM $wpdb->posts ORDER BY post_date DESC limit 0,1" );
        foreach ( $posts as $post )
        {
            $tm=strtotime($post->post_date);
        }
    }
    return $tm+$time_interval;
}
function hm_publish_pending_post()
{
    global $wpdb;
    $tm_now = time()+absint(get_option('gmt_offset')) * 3600;
    $now_date=date("Y-m-d H:i:s",$tm_now);
    $wpdb->get_results( "UPDATE $wpdb->posts set `post_status`='publish' WHERE `post_status`='pending' and `post_date`<'$now_date'" );
}
function hm_add_category($post_category)
{
    if(!function_exists('wp_insert_category')) @include "./wp-admin/includes/taxonomy.php";
    global $wpdb;
    $post_category_new=array();
    $post_category_list= array_unique(explode(",",$post_category));
foreach($post_category_list as $category)
{
        $cat_ID =intval($category);
        if($cat_ID==0)
        {
            $category = $wpdb->escape($category);
   $cat_ID = wp_insert_category(array('cat_name' => $category));
        }
        array_push($post_category_new,$cat_ID);
    }
    return $post_category_new;
}
function hm_strip_slashes($str){
//if (get_magic_quotes_gpc()) return stripslashes($str);
return $str;
}
function hm_strip_slashes_new($string, $force = 0) {
!defined('MAGIC_QUOTES_GPC') && define('MAGIC_QUOTES_GPC', get_magic_quotes_gpc());
if(!MAGIC_QUOTES_GPC || $force) {
  if(is_array($string)) {
   foreach($string as $key => $val) {
    $string[$key] = daddslashes($val, $force);
   }
  } else {
   $string = addslashes($string);
  }
}
return $string;
}
function hm_do_save_post($post_detail)
{
    global $post_author,$post_ping,$post_status,$translate_slug,$autoAddCategory,$post_next;
extract($post_detail);
    $post_title=trim(hm_strip_slashes($post_title));
$post_name=$post_title;
if($translate_slug) $post_name=hm_tranlate($post_name);
$post_name=sanitize_title( $post_name);
if( strlen($post_name) < 2 ) $post_name="";
   
    $post_content=hm_strip_slashes($post_content);
   
    $tags_input=str_replace("|||",",",$tags_input);

if(isset($post_date) &&$post_date)
  {
$post_date_gmt=$post_date;
$post_status='publish';
  }
  else
  {
  $tm=hm_get_post_time($post_next);
    $time_difference = absint(get_option('gmt_offset')) * 3600;
$post_date=date("Y-m-d H:i:s",$tm);
$post_date_gmt = gmdate('Y-m-d H:i:s', $tm-$time_difference);
    if($post_status=='next') $post_status='publish';
  }
   
    $post_category=hm_add_category($post_category);
   
    $post_data = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'post_name','tags_input');
$post_data = add_magic_quotes($post_data);
    $postID = wp_insert_post($post_data);
   
    if(!empty($post_meta_list)){
         $post_meta_array= array_unique(explode("|||",$post_meta_list));
         foreach($post_meta_array as $ppm)
         {
            $pp2=explode("$$",$ppm);
            if(!empty($pp2[0])&&!empty($pp2[1])) add_post_meta($postID,$pp2[0],$pp2[1],true);
         }
    }
if($post_ping)  generic_ping();
}
if($hm_action== "list")
{
hm_print_catogary_list();
}
elseif($hm_action== "update")
{
hm_publish_pending_post();
}
elseif($hm_action == "save" /*&&isset($_GET['secret'])&&$_GET['secret'] == $secretWord*/)
{
    if (isset($secretWord)&&($secretWord!=false)){
        if(!isset($_GET['secret']) || $_GET['secret'] != $secretWord)
        {
            die('接口密码错误,请修改配置文件或者修改发布参数,保持两者统一。');
        }
    }
   
//$post=$_POST;
extract($post);
if($post_title=='[标题]'||$post_title=='') die('标题为空');
if($post_content=='[内容]'||$post_content=='') die('内容为空');
if($post_category=='[分类id]'||$post_category=='') die('分类id为空');
if($wpmby_buy_link=='[链接]'||$wpmby_buy_link='') die('链接为空');
if($wpmby_price=='[价格]'||$wpmby_price='') die('价格为空');
if(!isset($post_date) ||strlen($post_date)<8) $post_date=false;
    if(!isset($post_author)) $post_author=$post_author_default;
    if(!isset($post_meta_list)) $post_meta_list="";
    hm_do_save_post(array('post_title'=>$post_title,
  'post_content'=>$post_content,
  'post_category'=>$post_category,
  'wpmby_price'=>$wpmby_price,
  'wpmby_buy_link'=>$wpmby_buy_link,
  'post_date'=>$post_date,
  'post_author'=>$post_author,
  'post_meta_list'=>$post_meta_list));
echo '发布成功';

}
else
{
    echo '非法操作['.$hm_action.']';
}
?>

发表于 2018-1-23 10:32:23 | 显示全部楼层
http://board.locoy.com/?post=192 可以模拟下论坛的这个接口
您需要登录后才可以回帖 登录 | 加入会员

本版积分规则

QQ|手机版|Archiver|火车采集器官方站 ( 皖ICP备06000549 )

GMT+8, 2024-11-22 13:22

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表