Page 1 of 1

API PHP Wrapper

PostPosted: Wed Dec 30, 2015 10:00 pm
by covarrubiasgg
Hello all,

Just to share with you, i am working on a wrapper to make it even easier to use the APIs on PHP

https://github.com/nerthux/Vicidial-PHP-API-WRAPPER

I know this is kinda dumb but i got bored about doing the same code over and over every time i need to customize something, to be honest i never changed the vicidial code i rather prefer using external scripts such as using the API, URL Scripts or even direct DB conections but never the source (maybe some day).

Anyway my intention is to make it even easier to write an external app for Vicidial the resulting code is very clear :)

Code: Select all
require 'vicidialAgentAPI.php';

try {
        $AgentAPI = new VicidialAgentAPI("127.0.0.1", "VicidialAPI", "gabriel", "Sup3rP4ss",true);
        $AgentAPI->pause("gabriel", "PAUSE");
        $AgentAPI->hangup("gabriel");
        $AgentAPI->dispo("gabriel", "SALE");
} catch (Exception $e) {
            echo 'Exception: ',  $e->getMessage(), "\n";
}


This is the first code that i publish ever, usually i code only for myself and i dont have practice at this, but i have to start somewhere.

I will keep adding more stuff :)

Re: API PHP Wrapper

PostPosted: Thu Dec 31, 2015 12:46 am
by mflorell
Thanks for posting this! It's always good to see how others implement API functions.

Related to this, did you see that we released a sample Agent API CRM_IFRAME codeset in svn/trunk this week?
http://vicidial.org/docs/CRM_EXAMPLE_SKIN.txt

Re: API PHP Wrapper

PostPosted: Sat Jan 02, 2016 12:32 pm
by covarrubiasgg
I have already check it, it is very nice because a lot of customers want to use something customized like that :) i will try to something like with my library :), today i decided to add another class for direct DB interactions.

BTW, i know this is not the best place, but i figured out that from the API Documentation it says:

To hangup the call, disposition it and then pause the agent, do the following in order:
docummentation wrote:
To hangup the call, disposition it and then pause the agent, do the following in order:
http://server/agc/api.php?source=test&u ... alue=PAUSE
http://server/agc/api.php?source=test&u ... up&value=1
http://server/agc/api.php?source=test&u ... s&value=AA


But it doesnt work in that specific order i have tried with my Class and directly on the browser, if run PAUSE first after dispo the agent will be avaiable.

i have tried PAUSE -> Hangup -> Dispo, Hangup -> PAUSE-> Dispo but the only one that it works is Hangup -> Dispo -> Pause


EDIT: Even Hangup -> Dispo -> PAUSE is not really working, it pause for a second and after that available again, not sure what going on :S

Re: API PHP Wrapper

PostPosted: Sat Jan 02, 2016 1:22 pm
by mflorell
Take a look at the code in the example I linked to, the pause should happen before the hangup, and in my code I allow for 2 seconds before processing the other API commands.

Re: API PHP Wrapper

PostPosted: Sat Jan 02, 2016 1:48 pm
by covarrubiasgg
Actually the same happens with the crm_example script.

After dispo, it pause the agent for 1 or 2 seconds and then available again. That happens when using the stop taking calls button.

I have try it by writing the url on a browser and it makes the same thing.

This is my testing enviroment: VERSION: 2.12-527a BUILD: 151229-1653 | Vicibox 6.0.4 | it is a virtual box that i use only for testing scripts and new features, not sure if it is caused by the virtual enviroment i have to try it on a real server

Re: API PHP Wrapper

PostPosted: Sat Jan 02, 2016 3:26 pm
by mflorell
We do have several clients using that method, and I did test the crm_iframe code on two separate systems before committing it. Your issue might be the campaign settings you are using.

Re: API PHP Wrapper

PostPosted: Sat Jan 02, 2016 3:59 pm
by covarrubiasgg
It works on my production server, campaign settings are the same in my testing environment, not sure what is causing the error, anyway :)

Thank you for you help and comments

API PHP Wrapper

PostPosted: Mon Jan 02, 2017 10:38 am
by RandalllTom
Is it an open API or can be passworded so that someone wont be taxing my timekoin server to stuff other than I want it to do?

Re: API PHP Wrapper

PostPosted: Mon Jan 02, 2017 11:36 am
by mflorell
The API is open, but its use depends on a valid User with API permissions.