tioffs / instalite
此包已被废弃,不再维护。未建议替代包。
一个易于使用的PHP类,用于访问Instagram的API。
1.0.0
2020-02-01 05:08 UTC
Requires
- php: >=7.2
This package is auto-updated.
Last update: 2021-10-29 02:52:16 UTC
README
用于与instagram交互的易于使用的类,功能最少
安装
使用Composer
composer require tioffs/instalite
示例
require_once __DIR__ . '/vendor/autoload.php'; use InstaLite\InstaLite; $instagram = new InstaLite("username", "password", "proxy"); /** search user (return array standart instagram) **/ $user = $instagram->searchUser('alex')->id(); /** search user (return array user id [1,2,3]) **/ $user = $instagram->searchUser('alex')->all(); /** send photo **/ $instagram->uploadPhoto(__DIR__ . '/img.jpg', 'text #hashtag'); /** send message direct **/ $instagram->sendMessage('text message', [1233, 1233, 1223]);
方法
搜索用户
搜索用户instagram,昵称,用户名,姓,名
$key = "search first name or username ..."; $user = $instagram->searchUser($key); $user->id(); /** return array user id **/ [1, 2, 3, 4, 5, 6] $user->all(); /** return array user standart formate instagram **/ [ [ pk: "" username: "" full_name: "" is_private: false profile_pic_url: "" profile_pic_id: "" is_verified: false has_anonymous_profile_picture: false mutual_followers_count: 0 social_context: "" search_social_context: "" friendship_status: {} latest_reel_media: 1580484486 seen: 0 ],[],[] ]
上传照片
发送照片,上传instagram
/** file photo mimetype JPEG **/ $photo = __DIR__ . '/image.jpg'; /** Message text and Hashtag **/ $message = 'Hello InstaGram'; $upload = $instagram->uploadPhoto($photo, $message); /** Result **/ if($upload) { /** upload photo sussecc **/ echo $upload; /** media id **/ }
发送消息
发送直接instagram消息
/** Array user id **/ $user = [12356456, 45645465]; /** Message text **/ $message = 'Hello InstaGram'; $send = $instagram->sendMessage($message, $user); /** Result **/ if($send) { /** message send sussecc **/ }
使用代理
支持socks5和http/https
/** socks5 **/ $instagram = new InstaLite("username", "password", "socks5://login:password@ip:port"); /** http/https **/ $instagram = new InstaLite("username", "password", "http://login:password@ip:port");
由 @tioffs 以♥制作