1. Go to this page and download the library: Download get-stream/stream library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
get-stream / stream example snippets
// Instantiate a new client, find your API keys in the dashboard.
$client = new GetStream\Stream\Client('YOUR_API_KEY', 'YOUR_API_SECRET');
// Instantiate a feed object
$userFeed = $client->feed('user', '1');
// If you want, you can set a custom http handler
$handler = new \GuzzleHttp\HandlerStack();
$stack->push(Middleware::mapRequest(function (RequestInterface $r) {
echo 'Sending request to Stream Feeds API: ' . $r->getUri() . PHP_EOL;
return $r;
}));
$client->setCustomHttpHandler($handler);
// Create a new activity
$data = [
'actor' => '1',
'verb' => 'like',
'object' => '3',
'foreign_id' => 'like:42',
];
$response = $userFeed->addActivity($data);
// The response will ctly by their ID or combination of foreign ID and time.
$response = $client->getActivitiesById(['74b9e88a-a684-4197-b30c-f5e568ef9ae2', '965f7ba5-8f1d-4fd1-a9ee-22d1a2832645']);
$response = $client->getActivitiesByForeignId(['fid:123', '2006-01-02T15:04:05.000000000'], ['fid:456', '2006-01-02T16:05:06.000000000']);
// The response will be the json decoded API response.
// {"duration": 45ms, "next": "/api/v1.0/feed/...", "results": [...]}
// Remove an activity by its ID
$userFeed->removeActivity('e561de8f-00f1-11e4-b400-0cc47a024be0');
// To remove activities by their foreign_id, set the "foreign id" flag to true.
$userFeed->removeActivity('like:42', true);
// When user 1 starts following user 37's activities
$userFeed->follow('user', '37');
// When user 1 stops following user 37's activities
$userFeed->unfollow('user', '37');
// Retrieve followers of a feed
$userFeed->followers();
// Retrieve feeds followed by $userFeed
$userFeed->following();
// Create a bit more complex activity with custom fields
$data = [
'actor' => 1,
'verb' => 'run',
'object' => 1,
'foreign_id' => 'run:42',
// Custom fields:
'course' => [
'name'=> 'Golden Gate park',
'distance'=> 10,
],
'participants' => ['Thierry', 'Tommaso'],
'started_at' => new DateTime('now', new DateTimeZone('Pacific/Nauru'),
];
// Add an activity and push it to other feeds too using the `to` field
$data = [
'actor' => '1',
'verb' => 'like',
'object' => '3',
'to' => [
'user:44',
'user:45',
],
];
$userFeed->addActivity($data);
// Batch adding activities
$activities = [
['actor' => '1', 'verb' => 'tweet', 'object' => '1'],
['actor' => '2', 'verb' => 'like', 'object' => '3'],
];
$userFeed->addActivities($activities);