Uploading photos to instagram, using a script

2019-03-11 10:20发布

问题:

Is it possible to upload photos from a webpage to Instagram, if so how do you do it?

I am wondering how to do this, so I can have a website where people can vote on their favourite photo and the one with most votes will be posted each day!

回答1:

You can use this API: https://github.com/mgp25/Instagram-API

And here is an example how to upload photo to Instagram:

<?php
require '../src/Instagram.php';
/////// CONFIG ///////
$username = '';
$password = '';
$debug    = false;
$photo    = '';     // path to the photo
$caption  = null;   // caption
//////////////////////
$i = new Instagram($username, $password, $debug);
try{
  $i->login();
} catch (InstagramException $e)
{
  $e->getMessage();
  exit();
}
try {
  $i->uploadPhoto($photo, $caption);
} catch (Exception $e)
{
  echo $e->getMessage();
}


回答2:

Try this: http://lancenewman.me/posting-a-photo-to-instagram-without-a-phone/ - works nicely for me, the first run will fail though as you would need to authorize the connection first. Just login to Instagram using the web site and select "It Was Me' when prompted - after that it works like a charm. Your account may also need to be active for this type of thing to work, I had an issue previously where API posts didn't work if there were no posts on the account so as a general rule of thumb we do a few manual posts first from a device.

Hope this helps you.



回答3:

Uploading on Instagram is possible.

POST https://instagram.com/api/v1/media/upload/

Check this code for example https://code.google.com/p/twitubas/source/browse/common/instagram.php

My challenge is out for people to fix this script so it is stand alone!