Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.