承接 jabranr/instagram-php-sdk 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

jabranr/instagram-php-sdk

Composer 安装命令:

composer require jabranr/instagram-php-sdk

包简介

PHP Client for Instagram API

README 文档

README

PHP client for Instagram API

Disclaimer: Although this project shares same name with famous social network but is NOT an official version of PHP SDKs for Instagram. The package is provided as it is with no guarantee or promises so please use at your own risk. Instagram is product of Instagram/Facebook.

Install & Usage

require('path/to/autoload.php');

use Instagram\InstagramClient;

$config = array(
	'client_id' => 'CLIENT_ID',
	'client_secret' => 'CLIENT_SECRET',
	'redirect_uri' => 'http://example.com'
);

try {
	$ig = new InstagramClient( $config );
} catch (Exception $e) {
	echo $e->getMessage();
}

if ( isset($ig) && $ig ) {


	/**
	 * Get a new access token with OAuth
	 */

	if ( isset($_GET['code']) ) {
		$ig->get_access_token( $fresh = true, $_GET['code'] );

		print_r( $ig->get_data() );

		/**
		 * Make API requests. See various methods underneath.
		 */
	}

	/**
	 * Or display a login with Instagram link for redirect user for OAuth
	 */
	else {
		echo '<a href="' . $ig->get_oauth_url() . '">Login with Insgatram</a>';
	}


	/**
	 * Or set an existing access token
	 */

	$ig->set_access_token( 'A_valid_access_token_obtained_previously' );

	print_r( $ig->get_data() );

	/**
	 * Make API requests. See various methods underneath.
	 */

}

Documentation

Use following methods to make requests to Instagram API.

Get Popular Media

try	{

	$media = $ig->popularMedia( (int) $count = 25 );
	$media = json_decode( $media );
	print_r( $media );

} catch(Exception $e) {
	echo $e->getMessage();
}

Search Media

/**
 * Atleast lat and lng are required to make requests to this endpoint
 */

try {
	$media = $ig->searchMedia(
					(float) $lat,
					(float) $lng,
					(UNIX_TIMESTAMP) $min_timestamp,
					(UNIX_TIMESTAMP) $max_timestamp,
					(int) $distance,
					(int) $count = 25 );

	$media = json_decode( $media );
	print_r( $media );
} catch(Exception $e) {
	echo $e->getMessage();
}

Get Media using an ID

try {
	$media = $ig->getMedia( (int) $media_id );
	$media = json_decode( $media );
	print_r( $media );
} catch(Exception $e) {
	echo $e->getMessage();
}

License

MIT License - © Jabran Rafique 2014

统计信息

  • 总下载量: 585
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 2
  • Forks: 7
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-12-02