eyeem / php-wrapper
Eyeem API V2 和 PHP 5.3 的包装器
Requires
- php: >=5.3.0
- ext-curl: *
This package is not auto-updated.
Last update: 2024-09-14 13:16:10 UTC
README
安装
使用Composer,创建一个composer.json
文件并运行php composer.phar install
命令来安装
{
"require": {
"eyeem/php-wrapper": "~2.1"
}
}
不使用Composer,克隆此仓库并包含自动加载文件
require_once __DIR__ . '/eyeem/API-php-wrapper/autoload.php';
然后实例化类并设置client_id和client_secret
$eyeem = new Eyeem(); $eyeem->setClientId('CLIENT_ID'); $eyeem->setClientSecret('CLIENT_SECRET');
资源
照片
查询对象:$photo = $eyeem->getPhoto('{photo_id}');
访问属性:echo $photo->caption;
或echo $photo->getCaption();
获取对象为数组:$array = $photo->toArray();
照片属性列表:'id', 'thumbUrl', 'photoUrl', 'width', 'height', 'updated', 'webUrl', 'user', 'caption', 'totalLikes', 'totalComments'
$photo->getUser();
返回一个用户对象。
访问资源集合:$comments = $photo->getComments();
或:foreach ($photo->getLikers() as $user) { echo $user->getFullname(); }
照片集合列表:'likers'(用户),'albums','comments'
发表评论:$photo->postComment('Nice Photo!');
点赞/取消点赞照片:$photo->like();
和$photo->unlike();
用户
$user = $eyeem->getUser('{user_id}');
访问属性:echo $user->fullname;
或echo $user->getFullname();
用户属性列表:'id', 'fullname', 'nickname', 'thumbUrl', 'photoUrl', 'totalPhotos', 'totalFollowers', 'totalFriends', 'totalLikedAlbums', 'totalLikedPhotos', 'webUrl', 'description'
用户集合列表:'photos', 'friends'(用户),'followers'(用户),'likedAlbums', 'likedPhotos', 'friendsPhotos', 'feed'(相册)
示例:foreach ($user->getFriends() as $friend) { echo $friend->getFullname(); }
关注/取消关注用户:$user->follow();
和$user->unfollow();
搜索用户:foreach ($eyeem->searchUsers('ramz') as $user) { echo $user->getFullname(); }
认证用户
扩展用户资源。
$authUser = $eyeem->getAuthUser();
更新用户信息:$authUser->update(array('fullname' => 'Santa Klaus'));
相册
$album = $eyeem->getAlbum('{album_id}');
相册属性列表:'id', 'name', 'thumbUrl', 'updated', 'webUrl', 'type', 'totalPhotos', 'totalLikers', 'totalContributors'
相册集合列表:'photos', 'likers'(用户),'contributors'(用户)
示例:foreach ($album->getPhotos() as $photo) { echo $photo->getCaption(); }
订阅/取消订阅相册:$album->subscribe();
和$album->unsubscribe();
将现有照片添加到相册:$album->addPhoto($photo);
和$album->addPhoto('{photo_id_}');
从相册中删除照片:$album->removePhoto($photo);
和$album->removePhoto('{photo_id_}');
搜索相册:foreach ($eyeem->searchAlbums('berlin') as $album) { echo $album->getName(); }
评论
评论属性列表:'id', 'photoId', 'updated', 'message', 'user'
$comment->getUser();
返回一个用户对象。
删除评论:$comment->delete();
上传照片
第1步
$photo = $eyeem->postPhoto(array('photo' => '@/home/me/a-nice-photo.jpg', 'caption' => 'A nice photo.'));
第2步
$filename = $eyeem->uploadPhoto('/home/me/a-nice-photo.jpg');
$photo = $eyeem->postPhoto(array('filename' => $filename, 'caption' => 'A nice photo.'));
许可
Copyright 2012-2013 EyeEm Mobile GmbH
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://apache.ac.cn/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.