SMP
💖 Chevereto Fan
Here is a small tutorial to schedule posting your images.
Step 1:
Create a folder "autoup" on server and a new file using the following code, change api_key, site_url, images_folder_path and save it as rand.php and upload it to "autoup" folder
Step 2:
Create a cron job as required with the following command
Step 3:
From now on upload your pictures to "autoup"
Step 1:
Create a folder "autoup" on server and a new file using the following code, change api_key, site_url, images_folder_path and save it as rand.php and upload it to "autoup" folder
Code:
<?php
// api key
$api_key = 'your_api_key'; //change this
// script install location
$site_url = 'http://www.yoursite.com'; //change this
// path to autoup folder
$images_folder_path = '/home/xxxx/public_html'; //change this
// folder name
$folder_name = '/autoup/'; // optional change
// extensions to be checked
$extensions = array('jpg','jpeg','gif','png','bmp');
// Images Array (SRC value)
$images = array();
// Open directory and read images
if ($handle = opendir($images_folder_path.$folder_name)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
// get file extension
$ext = strtolower(substr(strrchr($file, "."), 1));
if(in_array($ext, $extensions)) {
$images[] = $file;
}
}
}
if(!empty($images)) {
$rand_img = array_rand($images, 1);
$img_name = $images[$rand_img];
$img_url = $site_url.$folder_name.$img_name;
$api = $site_url .'/api/1/upload/?key='.$api_key.'&source='.$img_url.'&format=txt' ;
echo file_get_contents("$api");
if(unlink($img_name));
}
closedir($handle);
}
else
{
echo 'No images were found';
}
?>
Step 2:
Create a cron job as required with the following command
Code:
wget -O /dev/null -o /dev/null http://www.yoursite.com/autoup/rand.php
Step 3:
From now on upload your pictures to "autoup"