Posting Instagram photos using PHP

Viewed 59

I have been using PHP to post photos to my Facebook page for a couple of years.

I have set up an Instagram app with the instagram_content_publish permission but I cannot seem to translate the FB documentation into working PHP.

My FB post to a page works like this but I'm not a good-enough coder to figure out what to tweak to post the same photo to Instagram:

require_once 'facebook-sdk/autoload.php';

$fb = new Facebook\Facebook([
  'app_id' => 'xxx',
  'app_secret' => 'yyy',
  'default_graph_version' => 'v2.9',
  ]);

try 
{
   $args = array(
   $access_token'  => $page_token,
   'url'          => $urlofexistingphoto,
   'caption'       => 'Caption #instagram'
   );
   $post_id = $f->api("/$page_id/photos","post",$args);

} catch (FacebookApiException $e) 
{
   error_log($e);
   echo "Didn't work: $e\n";
}
0 Answers
Related