Last active
September 4, 2017 22:38
-
-
Save BrunoLagoa/ed2be5f9bf118afaa6a9d10ac7e1955e to your computer and use it in GitHub Desktop.
Autenticação Digest usando PHP POST para Web Service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$url = 'http://192.168.0.90:8088/asterisk/mxml'; | |
$data = 'Action=Login&Username=dashboard_enel&Secret=enel890678'; | |
$fp = fopen("cookie.txt", "w"); | |
fclose($fp); | |
$login = curl_init(); | |
curl_setopt($login, CURLOPT_COOKIEJAR, "cookie.txt"); | |
curl_setopt($login, CURLOPT_COOKIEFILE, "cookie.txt"); | |
curl_setopt($login, CURLOPT_TIMEOUT, 40000); | |
curl_setopt($login, CURLOPT_RETURNTRANSFER, TRUE); | |
curl_setopt($login, CURLOPT_URL, $url); | |
curl_setopt($login, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); | |
curl_setopt($login, CURLOPT_FOLLOWLOCATION, TRUE); | |
curl_setopt($login, CURLOPT_POST, TRUE); | |
curl_setopt($login, CURLOPT_POSTFIELDS, $data); | |
ob_start(); | |
$curl = curl_init(); | |
// Set some options - we are passing in a useragent too here | |
curl_setopt_array($curl, array( | |
CURLOPT_RETURNTRANSFER => 1, | |
CURLOPT_URL => 'http://192.168.0.90:8088/asterisk/mxml?Action=QueueStatus&Queue=8886&Member=Agent/19513', | |
CURLOPT_USERAGENT => 'Codular Sample cURL Request', | |
CURLOPT_COOKIEJAR => "cookie.txt", | |
CURLOPT_COOKIEFILE => "cookie.txt", | |
)); | |
$consulta = curl_exec ($curl); | |
dd('fim...'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment