定制 delta98/instaphp 二次开发

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

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

delta98/instaphp

最新稳定版本:2.1

Composer 安装命令:

composer require delta98/instaphp

包简介

A library for accessing Instagram's API (v2)

README 文档

README

This is version 2 of Instaphp. It's a complete rewrite from version 1 and is not backwards compatible. If you're using v1 and want to update to v2, you'll have to make a few changes. Some of the method names have changed and configuration is no longer an XML file. There are unit tests, but given the less than stellar reliability of Instagram's API, they are fairly useless.

If you're using composer, you shouldn't need to worry about dependancies. If you're not, you will have to figure out the include chain. The new version relies on GuzzleHttp.

It's not battle tested so I can't speak to it's reliability/speed/ease of use, but the unit test (generally) all pass. I will keep this in the development branch for a while until I think it's ready to move into master.

Usage

Here's a basic example showing how to get 10 popular posts...

<?php
	
	$api = new Instaphp\Instaphp([
		'client_id' => 'your client id',
		'client_secret' => 'your client secret',
		'redirect_uri' => 'http://somehost.foo/callback.php',
		'scope' => 'comments+likes'
	]);

	$popular = $api->Media->Popular(['count' => 10]);

	if (empty($popular->error)) {
		foreach ($popular->data as $item) {
			printf('<img src="%s">', $item['images']['low_resolution']['url']);
		}
	}
?>

Configuration

Configuration is now a simple array of key/value pairs. The absolute minimum required setting is client_id, but if you plan to allow users to login via OAuth, you'll need client_secret & redirect_uri. All the other settings are optional and/or have sensible defaults.

Key Default Value Description
access_token Empty This is the access token for an authorized user. You obtain this from API via OAuth
redirect_uri Empty The redirect URI you defined when setting up your Instagram client
client_ip Empty The IP address of the client. This is used to sign POST & DELETE requests. It's not required, but without the signing, users are more limited in how many likes/comments they can post in a given hour
scope comments+relationships+likes The scope of your client's capability
log_enabled TRUE Enable logging
log_level DEBUG Log level. See Monolog Logger
log_path ./instaphp.log Where the log file lives
http_useragent Instaphp/2.0; cURL/{curl_version}; (+http://instaphp.com) The user-agent string sent with all requests
http_timeout 6 Timeout for requests to the API.
http_connect_timeout 2 Timeout for http connect
debug FALSE Debug mode?
event.before Empty Callback called prior to sending the request to the API. Method takes a single parameter BeforeEvent
event.after Empty Callback called after a response is received from the API. Method takes a single parameter of CompleteEvent
event.error Empty Callback called when an error response is received from the API. Method takes a single parameter of ErrorEvent.

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 81
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-08-12