PHP cURL pull data from GenieACS

Richard Verbrugge richard.verbrugge at myhighspeed.ca
Wed May 20 13:53:48 EDT 2015


Hi folks,

 

I'm trying to use cURL to pull info from GenieACS using the API

So, first I would login:

$postdata =
$url."?utf8=".$utf8."&authenticity_token=".$authenticity_token."&username=".
$username."&password=".$password."&commit=".$commit;

 

This will probably fail due to the authenticity_token, I am not sure how to
obtain this.

Next I would run the query to obtain the ID of a device:

$postquery =
'http://genieacsserver/devices/?query=%7B%22summary.pppoeusername%22%3A%22'.
$pppoeusername;

 

Now cURL runs:

$ch2 = curl_init();

$agent = $_SERVER["HTTP_USER_AGENT"];

curl_setopt($ch2, CURLOPT_USERAGENT, $agent);

curl_setopt($ch2, CURLOPT_URL, $loginUrl );

curl_setopt($ch2, CURLOPT_POST, 1 );

curl_setopt($ch2, CURLOPT_POSTFIELDS, $postdata);

curl_setopt($ch2, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch2, CURLOPT_FOLLOWLOCATION, 1);

curl_setopt($ch2, CURLOPT_COOKIEJAR, 'cookie.txt');

curl_setopt($ch2, CURLOPT_COOKIEFILE, 'cookie.txt');

curl_setopt($ch2, CURLOPT_VERBOSE, 1);

curl_setopt($ch2, CURLOPT_STDERR, $fp);

   

$postResult = curl_exec($ch2); //login

curl_setopt($ch2, CURLOPT_URL, $postquery);

 

$exec = curl_exec($ch2); //get device ID

$info = curl_getinfo($ch2);

curl_exec($ch2);

 

 

curl_close($ch2);

 

echo $exec; //return the device ID to  obtain other data with

 

How can you obtain the authenticity_token via cURL ? Any input on this cude
is welcome!

 

Thanks,

/RV

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.genieacs.com/pipermail/users/attachments/20150520/3a35a5e2/attachment.html>


More information about the Users mailing list