livechat / api-client-php Goto Github PK
View Code? Open in Web Editor NEWPHP library with ready-to-use LiveChat API implementation.
PHP library with ready-to-use LiveChat API implementation.
CHAT_ID is a combination of both integers and strings, this effectively doesn't allow me to call, for instance getSingleChat('FG45GKJ65')
without an exception being thrown. Removing the call for ensureInteger()
in each method that accepts a CHAT_ID resolves the issue.
Is there any reason why this is in place when ID's aren't integers?
Hi!
I would like now how to work with API tickets. I doesn't find any example in php.
With the API of chats, visitors, no problems.
Thanks!
It would be helpful to include the "last seen" attribute for agent information. This information is displayed when browsing through agents within the normal UI.
Thanks.
I just updated the library to your most recent version 1.0
However, I get the following when I try to invoke a simple agents get.
Fatal error: Uncaught exception 'Exception' with message 'No such model: agents' in C:\xampp\livechat\src\LiveChat\Api\Client.php:52 Stack trace: #0 C:\xampp\livechat\index.php(9): LiveChat\Api\Client->__get('agents') #1 {main} thrown in C:\xampp\livechat\src\LiveChat\Api\Client.php on line 52
With same composer i have tried on other server and its working fine even on localhost its working fine except my server ... , can you please provide me exact php requirement to run this composer so that i will do changes in my server
When i am trying with the given composer on my server it giving me following error ๐
Fatal error: Uncaught exception 'Exception' with message '. ' in /home/chatagents/public_html/lc_api/vendor_new/livechat/api-client-php/src/LiveChat/Api/Rest/RestRequest.php:186 Stack trace: #0 /home/chatagents/public_html/lc_api/vendor_new/livechat/api-client-php/src/LiveChat/Api/Rest/RestRequest.php(157): LiveChat\Api\Rest\RestRequest->throwException(0) #1 /home/chatagents/public_html/lc_api/vendor_new/livechat/api-client-php/src/LiveChat/Api/Model/BaseModel.php(133): LiveChat\Api\Rest\RestRequest->getResponse() #2 /home/chatagents/public_html/lc_api/vendor_new/livechat/api-client-php/src/LiveChat/Api/Model/BaseModel.php(42): LiveChat\Api\Model\BaseModel->executeRequest('GET', 'chats?date_to=2...') #3 /home/chatagents/public_html/lc_api/vendor_new/livechat/api-client-php/src/LiveChat/Api/Model/Chats.php(20): LiveChat\Api\Model\BaseModel->executeGet('chats?date_to=2...') #4 /home/chatagents/public_html/lc_api/akash_api.php(23): LiveChat\Api\Model\Chats->get(Array) #5 {main} thrown in /home/chatagents/public_html/lc_api/vendor_new/livechat/api-client-php/src/LiveChat/Api/Rest/RestRequest.php on line 186
Do you think you could add a little note in the documentation for the Reports Method that specifies that $type
should include the full URI, not just the report name?
https://developers.livechatinc.com/rest-api/#!reports
IE: If I wanted to use "chatting_time", then $type
would need to be chats/chatting_time
, not just chatting_time
.
Another example would be Chat Ranking. $type
needs to be chats/ratings/ranking
.
A little heads up in the docs would be greatly appreciated.
Hi,
I am receiving this error when using the agent update function.
Invalid data input for postBody. Array expected
Here is my call:
$agent_specific = $LiveChatAPI->agents->update(array("name"=>"John Doe"));
I also tried this:
$agent_specific = $LiveChatAPI->agents->update("[email protected]",array("name"=>"John Doe"));
Thank you for your time.
When are you going to have tickets integrated in to this PHP client?
I suggest to add an annotation to the Client
class, because now PhpStorm highlights that calls:
$this->liveChatApi->chats->get(['visitor_id' => $identifier])
This should look like:
/**
* LiveChat Api Client class.
* @property \LiveChat\Api\Model\Chats chats
* @property \LiveChat\Api\Model\Goals goals
* @property \LiveChat\Api\Model\Agents agents
* and so on
*/
class Client
{
...
Additionally in the model classes there is unused import: use LiveChat\Api\Model\BaseModel;
.
I run the following curl command:
curl "https://api.livechatinc.com/agents/[email protected]" -u [email protected]:API_KEY -H X-API-Version:2 -X PUT -d "status=accepting+chats&max_chats_count=2"
However, the output I receive always returns the following JSON response.
Essentially, the field "status" is never updated.
{"login":"[email protected]","name":"Milder John Bernard Lisondra","login_status":"not accepting chats","permission":"administrator","daily_summary":0,"ticket_notifications":0,"job_title":"Support Agent","avatar":"livechat.s3.amazonaws.com/default/avatars/ab5b0666feffd67600206cd519fd77ea.jpg","notifications":{"new_visitor":0,"returning_visitor":0,"queued_visitor":1,"visitor_is_typing":0,"new_goal":1,"incoming_chat":1},"max_chats_count":2,"mute_all_sounds":0,"repeat_sound_notifications":0,"work_scheduler":{},"groups":[{"id":9,"name":"Testing"}],"status":"offline","last_logout":1436561366}
I have the following code.
Everything works well except when using the update method.
I am passing in the login and an array of parameters as outlined in the github documentation.
However, I don't get a response from the API.
Thanks.
require_once __DIR__ . '/vendor/autoload.php';
use LiveChat\Api\Client as LiveChat;
$LiveChatAPI = new LiveChat('[email protected]', 'xyz123');
$agents = $LiveChatAPI->agents->get();
foreach($agents as $agent){
if($agent->login == "[email protected]"){
print '<pre>';
print_r($agent);
print '</pre>';
}
}
$LiveChatAPI = new LiveChat('[email protected]', 'xyz123');
$user_login = "[email protected]";
$user_updates = array("name"=>"Milder Lisondra");
$LiveChatAPI->agents->update($user_login, $user_updates)
Here is the error which i am getting :-
Fatal error: Uncaught exception 'Exception' with message 'Something went wrong. StausCode: 0' in /home/chatagents/public_html/lc_api/vendor/livechat/api-client-php/src/LiveChat/Api/Rest/RestRequest.php:159 Stack trace: #0 /home/chatagents/public_html/lc_api/vendor/livechat/api-client-php/src/LiveChat/Api/Rest/RestRequest.php(145): LiveChat\Api\Rest\RestRequest->throwException(0) #1 /home/chatagents/public_html/lc_api/vendor/livechat/api-client-php/src/LiveChat/Api/Model/BaseModel.php(129): LiveChat\Api\Rest\RestRequest->getResponse() #2 /home/chatagents/public_html/lc_api/vendor/livechat/api-client-php/src/LiveChat/Api/Model/BaseModel.php(39): LiveChat\Api\Model\BaseModel->executeRequest('GET', 'chats?date_to=2...') #3 /home/chatagents/public_html/lc_api/vendor/livechat/api-client-php/src/LiveChat/Api/Model/Chats.php(20): LiveChat\Api\Model\BaseModel->get('chats?date_to=2...') #4 /home/chatagents/public_html/lc_api/akash_api.php(16): LiveChat\Api\Model\Chats->get(Array) #5 {main} thrown in /home/chatagents/public_html/lc_api/vendor/livechat/api-client-php/src/LiveChat/Api/Rest/RestRequest.php on line 159
For EU servers you need to change
const BASE_API_URL = 'https://api-fra.livechatinc.com/';
Docs: https://docs.livechatinc.com/rest-api/#list-all-agents
Currently agents->get($login) is present to fetch specific agent details.
Need something like this agents->get(array('status' => 'accepting chats'))
Is the repo still being maintained ? Can I make a PR ? Any guideline which I need to follow ?
I am trying to update tags for a chat. Relevant code is
$tags=array();
$tags[]="sale";
$LiveChatAPI->chats->updateTags($chat_id,$tags);
The request is successful, returns chat data as response but tags are never updated. Tags remain empty.
If I assign tag from admin panel and then update the tags for same chat via API, even those tags are removed.
Looks like some parameters' format issue. Kindly guide ?
Hi,
do You plan to extend API library to webhooks methods?
https://docs.livechatinc.com/rest-api/#webhooks
I really need them to integrate our system with LiveChat and I don't want to create my own lib just for 3 methods.
Plz help :)
Tickets
and Visitors
get()
methods are not compatible with BaseModel
.
Todo:
BaseModel
methods:
get()
-> executeGet()
,post()
-> executePost()
,put()
-> executePut()
,delete()
-> executeDelete()
,parent::get()
to $this->executeGet()
in models class (also post
, put
, delete
).A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.