PHP code example of carandclassic / talkjs

1. Go to this page and download the library: Download carandclassic/talkjs 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/ */

    

carandclassic / talkjs example snippets


use CarAndClassic\TalkJS\TalkJSClient;

$appId = 'my_app_id';
$secretKey = 'my_secret_key';
$talkJSClient = new TalkJSClient($appId, $secretKey);

$talkJSClient = app()->make(TalkJSClient::class, ['appId' => 'my_custom_app_id', 'secretKey' => 'my_custom_secret_key']);

$filters = [
    'limit' => 50,
    'startingAfter' => 'latestMessageId'
];

$appId = 'YOUR_APP_ID';
$secretKey = 'YOUR_SECRET_KEY';
$talkJSClient = new TalkJSClient($appId, $secretKey);

$talkJSClient->users->createOrUpdate('my_custom_id', [
    "name" => "Alice",
    "email" => ["[email protected]"],
    "welcomeMessage" => "Welcome!",
    "photoUrl" => "https =>//demo.talkjs.com/img/alice.jpg",
    "role" => "buyer",
    "phone" => ["+1123456789"],
    "custom" => [
        "foo" => "bar"
    ]
]);

$talkJSClient->users->find('my_user_id');

$talkJSClient->users->find($filters);

$talkJSClient->users->getConversations('my_user_id');

$talkJSClient->conversations->createOrUpdate('my_conversation_id', [
    'subject' => 'My new conversation',
    'participants' => ['my_user_id_1', 'my_user_id_2'],
    'welcomeMessages' => ['Welcome!'],
    'custom' => ['test' => 'test'],
    'photoUrl' => null
]);

$talkJSClient->conversations->get('my_conversation_id');

$talkJSClient->conversations->find();

$talkJSClient->conversations->join('my_conversation_id', 'my_user_id');

$talkJSClient->conversations->leave('my_conversation_id', 'my_user_id');

$talkJSClient->conversations->delete('my_conversation_id');

$notify = true; // Boolean, default true
$access = 'ReadWrite'; // ReadWrite or Read, default ReadWrite
$talkJSClient->conversations->updateParticipation('my_conversation_id', 'my_user_id', $notify, $access);

$custom = [
  'foo' => 'bar'
];

$talkJSClient->messages->get('my_conversation_id', $filters);

$talkJSClient->messages->find('my_conversation_id', 'message_id');

$talkJSClient->messages->postSystemMessage('my_conversation_id', $text, $custom);

$talkJSClient->messages->postUserMessage('my_conversation_id', $username, $text, $custom);

$talkJSClient->messages->edit('my_conversation_id', 'message_id', $text, $custom);

$talkJSClient->messages->delete('my_conversation_id', 'message_id');

php artisan vendor:publish --provider=CarAndClassic\\TalkJS\\Providers\\TalkJSServiceProvider