【发布时间】:2016-06-20 02:13:04
【问题描述】:
最近,我开始用这个http://elogram.readthedocs.io/en/stable/quickstart.html做一个小项目
它是一个 instagram API 库。
我已经学会了如何使用库做很多事情,但是在这里遇到了一个小问题。
我正在尝试构建一个网络应用程序,它可能会收到来自 instagram 的通知,并自动从 instagram 中提取我订阅的用户的最新帖子详细信息并保存到我的数据库中。
我可以从我为此目的创建的帐户中提取数据,我想要的是一种系统,其中
我在 instagram 上订阅了@exampleuser
@exampleuser 在 Instagram 上发布图片或视频
Instagram 发送通知,我的服务器收到推送通知
如果帖子存在,我的应用程序将检查数据库,如果不存在,则将其插入数据库。
我不知道如何实现。
这是我工作中的一个小sn-p,我正在使用Slim Framework。
$app->get('/new/getfrominsta', function () use ($app) {
$clientId = getenv('CLIENT_ID');
$clientSecret =$_ENV['CLIENT_SECRET'];
$redirectUrl = $_SERVER['REDIRECT_URI'];
$client = new Client($clientId, $clientSecret, $MyAccessToken, $redirectUrl); //use existing token to instantiate client class
$g= $client->users()->getMedia('1234567'); //1234567 is ID of user I intend to get his post
$self2 = json_encode($g->get());
foreach($self2 as $instapost)
{
$imgURL = $instapost->images->standard_resolution->url;
$InstaPostID = $instapost->link;
//$checkIfInstaPostExists = $InstaModel->CheckIfInstaPostExists($InstaPostID, $imgURL); //check if post in loop already exists in db.
print_r($instapost);
echo "<br/>";
}
exit();
});
由于沙盒模式,我可以获取用户最近的 20 篇媒体帖子。
我想要的是如何实现用户订阅通知。
【问题讨论】:
标签: php instagram-api