php - vbulletin 使用 CURL 和 PHP 发布帖子

标签 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);

        }

如果有任何建议,我将不胜感激……一定有什么东西藏在某处,但我就是看不到它……

谢谢, S

最佳答案

您不是在同一个帖子中添加第二张图片:您是在两个帖子中添加两张图片。当您通过欺骗 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 中的数组。

关于php - vbulletin 使用 CURL 和 PHP 发布帖子,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8028606/

相关文章:

php - jquery ajax 帖子

php - 无法使用 MAMP 通过本地主机建立与 MySQL 的连接

php - 无法从mysql检索数据并显示

.htaccess - 将 MyBB 页面重定向到 vBulletin

php - MYSQL中输入和输出之间的持续时间

mysql - 几年前创建了这个 vBulletin 论坛,现在它向我发送垃圾邮件错误

c# - C#中特殊字符的Url编码方法

php - FOREACH sql 表条目从另一个表获取结果

php - 将反斜杠插入数据库