PHP Tuenti API
, (*1)
Unofficial Tuenti API., (*2)
Setup and Configuration
Add the following to your composer.json file, (*3)
{
"require": {
"keyvanakbary/tuenti": "~1.0"
}
}
Update the vendor libraries, (*4)
curl -s http://getcomposer.org/installer | php
php composer.phar install
Usage
<?php
require 'vendor/autoload.php';
use Tuenti\Client;
use Tuenti\ApiError;
$t = new Client('foo@example.com', 'password');
try {
$profile = $t->getProfile($t->me());
} catch (ApiError $e) {
error_log($e->getMessage());
}
Quick Reference
Current User
The method me() returns your user id. You can use it in methods that require a $userId to retrieve your own data., (*5)
$t->getProfile($t->me());
Profile
Get profile for a given user, (*6)
getProfile($userId)
Get profile wall with statuses for a given user, (*7)
getProfileWallWithStatus($userId [, $page = 0 [, $size = 10]])
Get all your friends, (*8)
getFriends()
Set your status, (*9)
setStatus($status)
Notifications
Get personal notifications, (*10)
getPersonalNotifications()
Get friends notifications, (*11)
getFriendsNotifications([$page = 0 [, $size = 10]])
Messages
Get inbox message threads, (*12)
getInbox([$page = 0 [, $size = 10]])
Get sent message threads, (*13)
getSentBox([$page = 0 [, $size = 10]])
Get spam message threads, (*14)
getSpamBox([$page = 0 [, $size = 10]])
Retrieve messages from a given thread, (*15)
getThread($threadKey [, $page = 0 [, $size = 10]])
Send a message, (*16)
sendMessage($userId, $threadKey, $message)
Photos
Get user albums, (*17)
getAlbums($userId [, $page = 0 [, $size = 10]])
Get album photos for a given user, (*18)
getAlbumPhotos($userId, $albumId [, $page = 0])
Get all the tags for a photo, (*19)
getPhotoTags($photoId)
Add a post to a photo wall, (*20)
addPostToPhotoWall($photoId, $message)
Get the wall posts for a given photo, (*21)
getPhotoWall($photoId [, $page = 0 [, $size = 10]])
Iterate over all your albums and photos, (*22)
foreach ($t->getAlbums($t->me()) as $albumId => $album) {
// do something with $album
for ($i = 0; $i < $album['size']; $i = $i + Client::DEFAULT_PAGE_SIZE) {
$page = floor($i / Client::DEFAULT_PAGE_SIZE);
$photos = current($t->getAlbumPhotos($t->me(), $albumId, $page));
foreach ($photos as $photo) {
// do something with $photo
}
}
}
Events
Get upcoming events. You can include birthays, (*23)
getUpcomingEvents([$size = 10 [, $includeBirthdays = false]])
Retrieve event, (*24)
getEvent($eventId)
Get the wall for a given event, (*25)
getEventWall($eventId [, $page = 0 [, $size = 10]])