vbulletin posting posts with CURL and PHP
Asked Answered
H

1

8

I need to post a forum post on vbulletin via CURL and PHP, doesnt seem to be a hard job, however it has to have images, and I'm fine with uploading one image, but as soon as I add a second image, it seems to just redirect to the top thread in the forum i'm trying to post to?

Heres my code, it seems as if posting second image is just changing path to the image.. but it doesnt work?

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

        }

I'd appreciate any suggestions... there must be something hidding somewhere but I just can't see it..

Thanks, S

Halley answered 6/11, 2011 at 16:48 Comment(1)
I want to know what is $this->scrape->fetch doingMcgruter
I
1

You're not adding a second image to the one post: you're doing two posts with two images. As you're doing this by spoofing the POST parameters the first post gets actioned, and then the second post won't because vBull has protection against two posts being submitted quickly. The posts are (almost) identical so the second gets rejected. What you need to do is check the POST structure for including a second image and spoof that in a single call, not in two calls.

HOWEVER: as a general guide, such an approach would be considered "dangerous" in case things changes in the code.

You probably should look at using a the very functional API provided by vBulletin. https://members.vbulletin.com/api/vBulletin/vB_DataManager_ThreadPost.html https://members.vbulletin.com/api/vBulletin/vB_DataManager_Post.html

Like anything to do with vBull, it's a bit complicated but there's an excellent forum that (if you have a licence) can help you out. You'll see that the "POST" allows an array in the API.

Infinitude answered 20/10, 2013 at 11:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.