2011-11-06 69 views
8

我需要通過CURL和PHP在vbulletin上發佈論壇帖子,似乎並不是一項艱鉅的工作,但它必須具有圖像,而且我可以上傳一張圖片,但是隻要我添加第二個圖像,它似乎只是重定向到論壇中的頂級主題,我試圖發佈到?vbulletin發佈CURL和PHP的帖子

繼承人我的代碼,它似乎發佈第二個圖像只是改變圖像的路徑..但​​它不工作?

$post = array(
       'st' => '0', 
       'act' => 'Post', 
       's' => '', 
       'f' => '157', 
       'auth_key' => $this->scrape->fetchBetween("<input type='hidden' name='auth_key' value='", "'",$this->scrape->result), 
       'removeattachid' => '0', 
       'MAX_FILE_SIZE' => '0', 
       'CODE' => '01', 
       'post_key' => $this->scrape->fetchBetween("<input type='hidden' name='post_key' value='", "'",$this->scrape->result), 
       'TopicTitle' => $data['title'], 
       'TopicDesc' => '', 
       'tag' => $tag, 
       'bbmode' => 'normal', 
       'ffont' => '0', 
       'fsize' => '0', 
       'fcolor' => '0', 
       'LIST' => 'LIST ', 
       'helpbox' => 'Image (alt + g) [img]http://www.dom.com/img.gif[/img]', 
       'tagcount' => '', 
       'Post' => $description, 
       'enableemo' => 'yes', 
       'enablesig' => 'yes', 
       'iconid' => '0', 
       'FILE_UPLOAD' => "@".$data['img1'], 
       'attachgo' => 'Add This Attachment' 
     ); 
     $this->scrape->fetch('http://forum.lowyat.net/index.php?', $username, $post); 
     if(!empty($data['img2'])) { 
      $post = array(
       'st' => '0', 
       'act' => 'Post', 
       's' => '', 
       'f' => '157', 
       'auth_key' => $this->scrape->fetchBetween("<input type='hidden' name='auth_key' value='", "'",$this->scrape->result), 
       'removeattachid' => '0', 
       'MAX_FILE_SIZE' => '0', 
       'CODE' => '01', 
       'post_key' => $this->scrape->fetchBetween("<input type='hidden' name='post_key' value='", "'",$this->scrape->result), 
       'TopicTitle' => $data['title'], 
       'TopicDesc' => '', 
       'tag' => $tag, 
       'bbmode' => 'normal', 
       'ffont' => '0', 
       'fsize' => '0', 
       'fcolor' => '0', 
       'LIST' => 'LIST ', 
       'helpbox' => 'Image (alt + g) [img]http://www.dom.com/img.gif[/img]', 
       'tagcount' => '', 
       'Post' => $description, 
       'enableemo' => 'yes', 
       'enablesig' => 'yes', 
       'iconid' => '0', 
       'FILE_UPLOAD' => "@".$data['img2'], 
       'attachgo' => 'Add This Attachment'); 

      $this->scrape->fetch('http://forum.lowyat.net/index.php?', $username, $post); 
      echo "<pre>"; 
      print_r($post); 
      exit($this->scrape->result); 

     } 

我會很感激的任何建議...一定有什麼地方hidding,但我看不出它..

感謝, 小號

+2

我想知道什麼是$ this-> scrape-> fetch doing – Vineet1982

回答

1

你不添加第二個圖像的一個職位:你正在做兩個圖像的兩個職位。當您通過欺騙POST參數來執行此操作時,第一個帖子會被執行,然後第二個帖子將不會被執行,因爲vBull可以快速保護兩個帖子。帖子(幾乎)相同,所以第二個被拒絕。你需要做的是檢查POST結構中是否包含第二個圖像,並在一次調用中欺騙,而不是在兩次調用中。

但是,作爲一般指南,如果代碼發生變化,這種方法將被視爲「危險」。

你可能應該看看使用vBulletin提供的功能非常強大的API。 https://members.vbulletin.com/api/vBulletin/vB_DataManager_ThreadPost.htmlhttps://members.vbulletin.com/api/vBulletin/vB_DataManager_Post.html

和vBull一樣,它有點複雜,但有一個很好的論壇(如果你有許可證)可以幫助你。您會看到「POST」允許在API中使用數組。