forked from Ademking/InstaPoster
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"require": { | ||
"mgp25/instagram-php": "^3.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
/* | ||
___ _ _ _ _ | ||
| . | _| | ___ ._ _ _ | |__ ___ _ _ | |__<_> | ||
| |/ . |/ ._>| ' ' || / // . \| | || / /| | | ||
|_|_|\___|\___.|_|_|_||_\_\\___/`___||_\_\|_| | ||
By @AdemKouki | ||
GitHub : https://github.com/Ademking/InstaPoster | ||
Email : [email protected] | ||
Facebook : https://github.com/Ademking/InstaPoster | ||
*/ | ||
$username = 'INSTAGRAM_USERNAME'; | ||
$password = 'INSTAGRAM_PASSWORD'; | ||
|
||
$image_description = 'Your Description Here ...'; | ||
$img_url = 'https://picsum.photos/700/?random'; | ||
$photoFilename = "img/rand.jpg"; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
set_time_limit(0); | ||
date_default_timezone_set('UTC'); | ||
require __DIR__.'/vendor/autoload.php'; | ||
|
||
|
||
////////////////////// | ||
////////////////////// | ||
/////// CONFIG /////// | ||
|
||
require 'config.php'; | ||
|
||
$debug = true; | ||
$truncatedDebug = true; | ||
|
||
////////////////////// | ||
////////////////////// | ||
////////////////////// | ||
|
||
|
||
|
||
|
||
|
||
|
||
function download_img_from_url($imgurl , $photopath) { | ||
|
||
$fileName = "$photopath"; | ||
$fileUrl = "$img_url"; | ||
$ch = curl_init($fileUrl); // set the url to open and download | ||
$fp = fopen($fileName, 'wb'); // open the local file pointer to save downloaded image | ||
curl_setopt($ch, CURLOPT_FILE, $fp); // tell curl to save to the file pointer | ||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // tell curl to follow redirects | ||
curl_exec($ch); // fetch the image and save it with curl | ||
curl_close($ch); // close curl | ||
fclose($fp); // close the local file pointer | ||
|
||
} | ||
|
||
download_img_from_url($img_url, $photoFilename); | ||
|
||
|
||
$ig = new \InstagramAPI\Instagram($debug, $truncatedDebug); | ||
try { | ||
$ig->login($username, $password); | ||
} catch (\Exception $e) { | ||
echo 'Something went wrong: '.$e->getMessage()."\n"; | ||
exit(0); | ||
} | ||
try { | ||
|
||
|
||
|
||
|
||
$metadata = ['caption' => "$image_description"]; | ||
$ig->timeline->uploadPhoto($photoFilename, $metadata); | ||
echo "Upload Done!" ; | ||
|
||
|
||
|
||
|
||
|
||
} catch (\Exception $e) { | ||
echo 'Something went wrong: '.$e->getMessage()."\n"; | ||
} | ||
?> |