API PHP Wrapper

Discussions about development of VICIDIAL and astGUIclient

Moderators: gerski, enjay, williamconley, Op3r, Staydog, gardo, mflorell, MJCoate, mcargile, Kumba, Michael_N

API PHP Wrapper

Postby covarrubiasgg » Wed Dec 30, 2015 10:00 pm

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 :)
covarrubiasgg
 
Posts: 420
Joined: Thu Jun 10, 2010 10:20 am
Location: Tijuana, Mexico

Re: API PHP Wrapper

Postby mflorell » Thu Dec 31, 2015 12:46 am

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
mflorell
Site Admin
 
Posts: 18387
Joined: Wed Jun 07, 2006 2:45 pm
Location: Florida

Re: API PHP Wrapper

Postby covarrubiasgg » Sat Jan 02, 2016 12:32 pm

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
covarrubiasgg
 
Posts: 420
Joined: Thu Jun 10, 2010 10:20 am
Location: Tijuana, Mexico

Re: API PHP Wrapper

Postby mflorell » Sat Jan 02, 2016 1:22 pm

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.
mflorell
Site Admin
 
Posts: 18387
Joined: Wed Jun 07, 2006 2:45 pm
Location: Florida

Re: API PHP Wrapper

Postby covarrubiasgg » Sat Jan 02, 2016 1:48 pm

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
covarrubiasgg
 
Posts: 420
Joined: Thu Jun 10, 2010 10:20 am
Location: Tijuana, Mexico

Re: API PHP Wrapper

Postby mflorell » Sat Jan 02, 2016 3:26 pm

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.
mflorell
Site Admin
 
Posts: 18387
Joined: Wed Jun 07, 2006 2:45 pm
Location: Florida

Re: API PHP Wrapper

Postby covarrubiasgg » Sat Jan 02, 2016 3:59 pm

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
covarrubiasgg
 
Posts: 420
Joined: Thu Jun 10, 2010 10:20 am
Location: Tijuana, Mexico

API PHP Wrapper

Postby RandalllTom » Mon Jan 02, 2017 10:38 am

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?
http://seofabryka.com
RandalllTom
 
Posts: 2
Joined: Mon Jan 02, 2017 7:20 am
Location: Poland

Re: API PHP Wrapper

Postby mflorell » Mon Jan 02, 2017 11:36 am

The API is open, but its use depends on a valid User with API permissions.
mflorell
Site Admin
 
Posts: 18387
Joined: Wed Jun 07, 2006 2:45 pm
Location: Florida


Return to Development

Who is online

Users browsing this forum: No registered users and 36 guests