News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Batch posting?

Started by themavesite, May 19, 2016, 07:06:52 AM

Previous topic - Next topic

themavesite

Quote from: BigMike on October 01, 2014, 04:32:03 PM
Update, it's working great! Just did my first live test by posting 201 images across 50 replies with one mouse click!! http://board.marlincrawler.com/index.php?topic=97633 (this example is a mirror from our Facebook Album (link) using JSON. One mouse click Facebook Album to Forum Integration FTW!).

SMF never ceases to amaze!

Regards,
BigMike

Dear BigMike, I'm looking for the exact thing to paste 100s of wallpapers, one in reach reply.

I'm using imgur links so every link is [img]http://i.imgur.com/randomchars.jpg[/img]
I have all these in a long list below eachother

[img]http://i.imgur.com/randomchars.jpg[/img]
[img]http://i.imgur.com/randomchars1.jpg[/img]
[img]http://i.imgur.com/randomchars2.jpg[/img]
[img]http://i.imgur.com/randomchars3.jpg[/img]

etc

How would I accomplish posting them using your method?
TMS Forums
Since 2008 and still going strong! Join today! http://forums.themavesite.com/index.php

themavesite

<?php
  
require("SSI.php");
  require(
"Sources/Subs-Post.php");
  
// Bounce to log-in page if not logged in as Admin
  
isAllowedTo('admin_forum');

  echo 
'<html><body>';

  
// Set some defaults -- modify these as desired
  
$topicOptions['id'] = '31559'// Topic ID
  
$topicOptions['board'] = '54'// Board ID
  
$posterOptions['id'] = '1';  // Poster ID
  
$msgOptions['subject'] = 'Re: test'// Subject of post
  
$msgOptions['body'] = 'test2'// The content of the post

  // Don't touch these
  
$posterOptions['name'] = $user_info['name'];
  
$posterOptions['email'] = $user_info['email'];
  
$posterOptions['ip'] = $user_info['ip'];

         
$array = array( '1''2');
         foreach( 
$array as $msgOptions['body'] ) {
            
createPost($msgOptions$topicOptions$posterOptions);
         }

  
// Create the reply!
  

  
echo '<a href="' $boardurl '/index.php?topic=' $topicOptions['id'] . '">Click here to go view the new reply!</a>';

  echo 
'</body></html>';
?>


This works!
TMS Forums
Since 2008 and still going strong! Join today! http://forums.themavesite.com/index.php

Irisado

Topic split.  Please avoid reviving two year old topics that have been marked as solved.  It's always better to start a new topic making reference to the old one in such cases :).
Soñando con una playa donde brilla el sol, un arco iris ilumina el cielo, y el mar espejea iridescentemente

BigMike

Hello themavesite,

I wrote a 129 line PHP script that I run from my server. It has many features such as pulling images from Facebook (via json_decode), error checking, and post timestamp handling to prevent duplicate posts/replies. Here is the gist of it:

Create a new PHP file that will be placed in your forum's root directory...

<?php

  
require("SSI.php");
  require(
"Sources/Subs-Post.php");
  
isAllowedTo('admin_forum');                         // Kick to log-in page if not logged in as Admin


Then add your images to a variable...


$bbc = '[img]http://i.imgur.com/randomchars.jpg[/img]<br />[img]http://i.imgur.com/randomchars1.jpg[/img]<br />[img]http://i.imgur.com/randomchars2.jpg[/img]<br />[img]http://i.imgur.com/randomchars3.jpg[/img]';


Now run this through to your forum. My code runs multiple posts through an array so I'm using a function to handle this as follows:


  function post($tid, $tboard, $bbc) {
    $topicOptions['id'] = $tid;                       // Topic ID
    $topicOptions['board'] = $tboard;                 // Board ID
    $posterOptions['id'] = '122';                     // Poster ID
    $posterOptions['name'] = $user_info['name'];
    $posterOptions['email'] = $user_info['email'];
    $posterOptions['ip'] = $user_info['ip'];
    for ($i=0; $i<sizeof($output); $i++) {
      $msgOptions['subject'] = 'Picture Group #' . ($i + 1);   // Subject of each reply
      $msgOptions['body'] = $output[$i];              // The content of each reply
      createPost($msgOptions, $topicOptions, $posterOptions);  // Create the replies!
    }
  }


Where
$tid = Topic ID you'd like to post to
$tboard = The board ID where this topic exists
$pid = The user ID for the account that will be "posting" to the topic

This assumes $output[0] is the first post, $output[1] is another, $output[2] another, and so on. I did this so that I don't have a bunch of images all on one post which would make the page long and server load difficult.

Here it is for a single variable:


post('123','12', $bbc);

function post($tid, $tboard, $bbc) {
  $topicOptions['id'] = $tid;                       // Topic ID
  $topicOptions['board'] = $tboard;                 // Board ID
  $posterOptions['id'] = '122';                     // Poster ID
  $posterOptions['name'] = $user_info['name'];
  $posterOptions['email'] = $user_info['email'];
  $posterOptions['ip'] = $user_info['ip'];
  $msgOptions['subject'] = 'Look at my pictures! ^__^';   // Subject of the reply
  $msgOptions['body'] = $output;              // The content of the reply
  createPost($msgOptions, $topicOptions, $posterOptions);  // Create the reply!
}


Let me know if you have any questions. After looking back at some threads I've created I see Facebook changed their image URLs. So now we have a bunch of dead image links. Sucks!

Regards,
BigMike

Advertisement: