Post 使用 Oauth2 在 Instagram 上的图片 - PHP

Post an image on instagram using Oauth2 - PHP

我只想 post 一张图片 在 instagram 上使用 Oauth2 & PHP 非常类似于墙 post 用于 Facebook 和推文post 推特喜欢:

用户从我的网站点击 在 Instagram 上分享 按钮,他们重定向到 Instagram 应用程序批准页面,他们批准并且图像在他们的帐户上 posted .

为了这个要求,我几乎搜索了整个互联网。但是我没有得到实现这个的确切代码。

我已经检查过这些:

https://github.com/mgp25/Instagram-API

https://github.com/cosenary/Instagram-PHP-API

有人说不可能,Instagram不允许。

所以我想要的只是一个明确的答案,是否可能?如果是那么怎么办?

谢谢

明确答案

这是不可能的,也不是官方的。所有非官方 API/包/库...无论您发现什么,都只是对 Instagram 应用程序生成的流量进行逆向工程的初步尝试。

所以他们可能会工作一段时间,但随后 Instagram 会屏蔽他们。

想一想。如果有官方的方法可以将内容上传到 instagram,就会有很多替代应用程序和垃圾邮件发送者使用它。

如果你不相信我,check the official API documentation。没有参考图片上传

Post istagram image with caption using facebook api(business account - without login) 
ref - https://github.com/facebookarchive/php-graph-sdk

<?php 
define('FACEBOOK_SDK_V4_SRC_DIR', __DIR__.'/src/Facebook/');
require_once(__DIR__.'/src/Facebook/autoload.php');
    $instaData = [
                 'image_url' => 'image_url',
                 'caption' => htmlspecialchars('your message')
                 ];     
$pageAccessToken ='your access token';
$fb = new Facebook\Facebook([
 'app_id' => 'fb_app_id',
 'app_secret' => 'app secrect',
 'default_graph_version' => 'v12.0',
]);
try {
 $response = $fb->post('INSTA_PAGE_ID/media/?', $instaData, $pageAccessToken);
} catch(Facebook\Exceptions\FacebookResponseException $e) {
 echo 'Graph returned an error: '.$e->getMessage();
 exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
 echo 'Facebook SDK returned an error: '.$e->getMessage();
 exit;
}
$graphNode = $response->getGraphNode();
$creation_id = json_decode($graphNode);
$publish_image = [
                 'creation_id' => intval($creation_id->id)
                ];
try {
 $response1 = $fb->post('INSTA_PAGE_ID/media_publish/?', $publish_image, $pageAccessToken);
} catch(Facebook\Exceptions\FacebookResponseException $e) {
 echo 'Graph returned an error: '.$e->getMessage();
 exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
 echo 'Facebook SDK returned an error: '.$e->getMessage();
 exit;
}
echo "<pre>"; print_r($response1); echo "</pre>";
?>