ollieltd/instagram-bundle
Composer 安装命令:
composer require ollieltd/instagram-bundle
包简介
Use Instaphp by sesser (Randy) as a Symfony2 service. Adapted to use Instaphp v2 as a dependency.
关键字:
README 文档
README
Uses Instaphp by sesser as a Symfony2 service. Adapted to use Instaphp v2 as a dependency.
Installation
Install this bundle as usual by adding to composer.json:
"ollieltd/instagram-bundle": "dev-master"
After installing above module you need to update your composer
composer update
Register the bundle in app/AppKernel.php:
// app/AppKernel.php public function registerBundles() { return [ // ... new Oh\InstagramBundle\OhInstagramBundle(), ]; }
Add the following to app/config/config.yml:
imports: - { resource: "@OhInstagramBundle/Resources/config/services.yml" } oh_instagram: instaphp: config: client_id: %instagram_api_client_id% client_secret: %instagram_api_client_secret% access_token: %instagram_api_access_token% # (optional)
And add these parameters:
instagram_api_client_id: YOUR_API_ID instagram_api_client_secret: YOUR_API_SECRET instagram_api_access_token: YOUR_API_ACCESS_TOKEN # (optional)
Most of the Instaphp configuration keys can be set in
oh_instagram.instaphp.config. See
Configuring Instaphp
And if you're OK with the provided routes, add these to
app/config/routing.yml:
OhInstagramBundle: resource: "@OhInstagramBundle/Resources/config/routing.yml" prefix: /
Usage (Controller)
$query = "snoopdogg"; /** * @var InstaphpAdapter */ $api = $this->get('instaphp'); $userId = $api->Users->FindId($query); $media = $api->Users->Recent($userId);
You can also test if a user is logged in:
//is a user logged in? $loggedIn = $this->get('instaphp_token_handler')->isLoggedIn();
Usage (Twig)
You should set up your Instagram API account to callback to
the OhInstagramBundle_callback route, which you can set yourself, or use the
one provided which is http://yourserver.com/instaphp/callback.
For quick testing purposes you can add this to your routing:
OhInstagramBundle_check: path: /checkInstagram defaults: { _controller: OhInstagramBundle:Instagram:instagramLoginStatus }
Then navigate to /checkInstagram to try out the login button.
There's a login button included in the views. Just implement this line in your Twig template:
{{ render(controller('OhInstagramBundle:Instagram:instagramLoginStatus')) }}
Instagram Auth Token
There are 2 TokenHandlers included:
CookieToken
The Instagram auth code is stored in a cookie
services: instaphp_token_handler: class: Oh\InstagramBundle\TokenHandler\CookieToken
UserToken
The Instagram auth code is stored in the User Entity. The methods
setInstagramAuthCode() and getInstagramAuthCode() must be implemented on
your User. When the login call is returned from Instagram, the code is set and
the user is persisted and flushed in the Handler. There is an interface which is
recommended that you use on your entity:
Oh\InstagramBundle\TokenHandler\UserTokenInterface
services: instaphp_token_handler: class: Oh\InstagramBundle\TokenHandler\UserToken arguments: ["@security.context", "@doctrine.orm.default_entity_manager"]
Both
This will look to see if the user can be retrieved from the context and if it can't it will store the auth code in a cookie.
services: instaphp_user_token_handler: class: Oh\InstagramBundle\TokenHandler\UserToken arguments: ["@security.context", "@doctrine.orm.default_entity_manager"] instaphp_cookie_token_handler: class: Oh\InstagramBundle\TokenHandler\CookieToken instaphp_token_handler: class: Oh\InstagramBundle\TokenHandler\TokenManager arguments: ["@instaphp_user_token_handler", "@instaphp_cookie_token_handler"]
You can also implement your own TokenHandlerInterface to store the auth code somewhere else, for example in the session.
Tests
@todo
Credits
- Ollie Harridge (ollietb) as the author.
- Randy (sesser) for writing Instaphp
ollieltd/instagram-bundle 适用场景与选型建议
ollieltd/instagram-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 19.77k 次下载、GitHub Stars 达 10, 最近一次更新时间为 2015 年 01 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「Symfony2」 「api」 「instagram」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ollieltd/instagram-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ollieltd/instagram-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ollieltd/instagram-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Handles basic OAuth/OAuth2 authentication along with classes for common services
Craft CMS plugin to receive Instagram feed data as variable in templates.
Simple Sharing generates social media share links within CP entry pages, allowing you to quickly & easily share entries.
A PSR-7 compatible library for making CRUD API endpoints
An easy-to-use PHP Class for accessing Instagram's API.
Symfony2 Barcode Generator Bundle with Twig function extension
统计信息
- 总下载量: 19.77k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 10
- 点击次数: 17
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-01-05