vbulletin用CURL和PHP发布帖子

Sau*_*ius 8 php vbulletin

我需要通过CURL和PHP发布关于vbulletin的论坛帖子,看起来不是很难,但是它必须有图像,我可以上传一个图像,但是一旦我添加第二个图像,它似乎只是重定向到我试图发布到论坛的顶级主题?

继承我的代码,似乎发布第二个图像只是改变图像的路径..但​​它不起作用?

$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);

        }
Run Code Online (Sandbox Code Playgroud)

我很感激任何建议......必须有某些东西隐藏在某处,但我只是看不到它..

谢谢,S

Rob*_*bie 1

您不会在一篇文章中添加第二张图片:您正在使用两张图片发布两篇文章。当您通过欺骗 POST 参数来执行此操作时,第一个帖子会被执行,然后第二个帖子不会被执行,因为 vBull 可以防止两个帖子快速提交。这些帖子(几乎)相同,因此第二个帖子被拒绝。您需要做的是检查 POST 结构是否包含第二个图像,并在一次调用中(而不是在两次调用中)欺骗该图像。

但是:作为一般指南,如果代码发生变化,这种方法将被视为“危险”。

您可能应该考虑使用 vBulletin 提供的功能强大的 API。https://members.vbulletin.com/api/vBulletin/vB_DataManager_ThreadPost.html https://members.vbulletin.com/api/vBulletin/vB_DataManager_Post.html

就像与 vBull 相关的任何事情一样,它有点复杂,但有一个很棒的论坛(如果您有许可证)可以帮助您。您将看到“POST”允许 API 中使用数组。