I'm building up a url to execute with curl. the url will call an api for the LMS that I'm using. Before being able to call anything else, you need to receive a token from the LMS to put in the url. I have gotten the token from the api, and I can echo it and it shows up just fine, when I echo the url after appending the token to it, it doesn't show up.
curl_setopt($c, 'CURLOPT_RETURNTRANSFER', true);
$res = curl_exec($c);
curl_close($c);
$start = strpos($res,"<token>");
$end = $start+37;
$token = substr($res,$start+7,$end-$start);
echo "{$token}<br />";
$url = "/www/api2.php?action=create_user";
$url .= "&login=" . urlencode($username);
$url .= "&password=" . urlencode($password);
$url .= "&name=" . urlencode($data['first_name']);
$url .= "&surname=" . urlencode($data['last_name']);
$url .= "&email=" . urlencode($email);
$url .= "&languages=english";
$url .= "&token=" . $token;
echo "{$url}<br />";
Output of the echo "{$url}<br />";
/www/api2.php?action=create_user&login=foobar3130&password=6116b3f29c&name=Foo&surname=Bar&email=foobar%40gmail.com&languages=english&token=
Output of echo "{$token}<br />";
pUCu2BUAE1heAyQ93fApfhvDE1bjKd
Edit
I added a check to see if $start
was false, and it is false. I guess its not actually the token that gets echo'd because if I comment that line out, the string that I have for the token output still gets printed. I'm not sure what it would even be from.
Edit 2 I now have it returning xml but I am not sure how to parse it to get the token. It returns:
<xml><token>Fp1rYkds4fSuTAQxTvLvSiW5NE2FJz</token></xml>