Jump to content

[SOLVED] PHP Wrapper Problems


tigomark

Recommended Posts

Hello all,

 

I am having problems getting a string comparison to work in my wrapper script

 

<?php

$customer = $_REQUEST['customer'];
$username = $_REQUEST['username'];
$password = $_REQUEST['password'];


$mystring = strstr("<error ver=\"1.0\">", "</error>" );

$url = "https://$customer.mysite.net/interface.php?action=showopen&operation=showassets&format=xml&opstatus=crit&username=$username&password=$password";


function auth_curl($url){
   	$curl = curl_init();
   	curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
   	$html = curl_exec($curl); // execute the curl command



    if (false == strpos($mystring, "error")){
$html = "<loginsuccess>Yes</loginsuccess>";
    }else{

    $html = "<loginsuccess>No</loginsuccess>";
    }
	curl_close($curl); // close the connection
	return $html; // and finally, return $html
}

// uses the function and displays the text off the website
$text = auth_curl($url);
echo $text;

?>

 

 

Now the output of the xml is as follows

 

<error ver="1.0">

<action>showopen</action>

<code>109</code>

<message>Failed to authenticate user 'user'</message>

</error>

 

so what I am trying to do is grab everything between the error tag and if I get the error tag I want to show the <loginsuccess>No</loginsuccess> else give them access to the app.

 

Any help would be great

Link to comment
https://forums.phpfreaks.com/topic/87139-solved-php-wrapper-problems/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.