AGI script and queue

I am trying to run and AGI script when a call get to a queue and when an agent take the call ,and send to php script the queue name and the agent extension number ,Any help would be incredibly appreciated.
exten => _X.,n,Queue(toqueue.php)

In extensions_override_freepbx.conf:

include => macro-auto-blkvm-custom
exten => s,1,Set(_MACRORESULT=)
exten => s,n,Set(CFIGNORE=)
;exten => s,n(weasels),System(sh ${CALLERID(num)}) ; Here a example of script
exten => s,n,Noop(${REALCALLERIDNUM} - ${CALLERID(num)})
exten => s,n,Noop(${REALCALLERIDNUM} - ${CALLERID(num)})
exten => s,n,Set(FORWARD_CONTEXT=from-internal)
exten => s,n,Set(MASTER_CHANNEL(FORWARD_CONTEXT)=from-internal)
exten => s,n,Macro(blkvm-clr,)
exten => s,n,ExecIf($[!${REGEX("[^0-9]" ${DIALEDPEERNUMBER})} && “${DB(AMPUSER/${AMPUSER}/cidname)}” != “”]?Set(MASTER_CHANNEL(CONNECTEDLINE(num))=${DIALEDPEERNUMBER}))
exten => s,n,ExecIf($[!${REGEX("[^0-9]" ${DIALEDPEERNUMBER})} && “${DB(AMPUSER/${AMPUSER}/cidname)}” != “”]?Set(MASTER_CHANNEL(CONNECTEDLINE(name))=${DB(AMPUSER/${DIALEDPEERNUMBER}/cidname)}))

How can i link a php script that I have on my server to a queue events for example when a call go to the queue I execute the script and when the agent take the call execute again the script

Thanks !