定制 espresso-dev/instagram-php 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

espresso-dev/instagram-php

最新稳定版本:v1.1.2

Composer 安装命令:

composer require espresso-dev/instagram-php

包简介

A simple PHP class for accessing the Instagram API

README 文档

README

A simple PHP wrapper for the Instagram API. Based on the original Instagram-PHP-API by Christian Metz

Latest Stable Version License Total Downloads

Composer package available.

Requirements

  • PHP 5.6 or higher
  • cURL
  • Facebook Developer Account
  • Facebook App

Get started

To use the Instagram API, you will need to register a Facebook app and configure Instagram Basic Display. Follow the getting started guide.

Installation

I strongly advise using Composer to keep updates as smooth as possible.

$ composer require espresso-dev/instagram-php

Initialize the class

use EspressoDev\Instagram\Instagram;

$instagram = new Instagram([
    'appId' => 'YOUR_APP_ID',
    'appSecret' => 'YOUR_APP_SECRET',
    'redirectUri' => 'YOUR_APP_REDIRECT_URI'
]);

echo "<a href='{$instagram->getLoginUrl()}'>Login with Instagram</a>";

Authenticate user (OAuth2)

// Get the OAuth callback code
$code = $_GET['code'];

// Get the short lived access token (valid for 1 hour)
$token = $instagram->getOAuthToken($code, true);

// Exchange this token for a long lived token (valid for 60 days)
$token = $instagram->getLongLivedToken($token, true);

echo 'Your token is: ' . $token;

Get user profile

// Set user access token
$instagram->setAccessToken($token);
// Get the users profile
$profile = $instagram->getUserProfile();

echo '<pre>';
print_r($profile);
echo '</pre>';

Get user media

// Set user access token
$instagram->setAccessToken($token);
// Get the users media
$media = $instagram->getUserMedia();

echo '<pre>';
print_r($media);
echo '</pre>';

统计信息

  • 总下载量: 17.96k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 9
  • 点击次数: 0
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 9
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-09-23