Skip to content

Instantly share code, notes, and snippets.

@BrightnBubbly
Created April 9, 2020 12:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BrightnBubbly/c4a5341d820044dc262c710afca87df9 to your computer and use it in GitHub Desktop.
Save BrightnBubbly/c4a5341d820044dc262c710afca87df9 to your computer and use it in GitHub Desktop.
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use GetStream\StreamChat\Client as StreamClient;
use App\User;
use App\Channel;
use Illuminate\Support\Facades\Auth;
class ChatController extends Controller
{
protected $client;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->client = new StreamClient(
getenv("STREAM_API_KEY"),
getenv("STREAM_API_SECRET"),
null,
null,
9 // timeout
);
}
/**
* Generate Token from Stream Chat
*/
public function getnerateToken(Request $request)
{
return response()->json([
'token' => $this->client->createToken($request->input('username'))
], 200);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment