I've a php script that if the user ahs the privilege to download and image the image is sent to webbrowser but if the user has not the privileges and xml with the info is displayed.
phpcode:
if($this->can_download($user->id)){
$id = int_escape($_GET['id']);
$image = Image::by_id($id);
if(!is_null($image)) {
$page->set_mode("data");
$page->set_type($image->get_mime_type());
$file = $image->get_image_filename();
$page->set_data(file_get_contents($file));
//WE UPDATE THAT THE USER HAS DOWNLOADED A FILE.
$this->update_database($user->id, "download");
} else {
$xml = "<status>\n";
$xml .= "<info code=\"145\" message=\"Image does not exists.\"/>\n";
$xml .= "</status>";
$page->set_type("application/xml");
$page->set_data($xml);
}
}else {
$xml = "<status>\n";
$xml .= "<info code=\"145\" message=\"Yor has reached your daily limit.\"/>\n";
$xml .= "</status>";
$page->set_type("application/xml");
$page->set_data($xml);
}
How can I identify the type of response with vb.net to save the image if it is or send the xml to a parser to use it?
This my vb code:
Dim PerformedUserUrl As String = UserUrl & "?username=" & username & _
"&password=" & password
Dim WebRequest As HttpWebRequest = HttpWebRequest.Create(PerformedUserUrl)
WebRequest.Method = "GET"
Dim webResponse As HttpWebResponse = Nothing
Dim stReader As StreamReader = Nothing
Dim response as string
Try
webResponse = WebRequest.GetResponse()
stReader = New StreamReader(webResponse.GetResponseStream())
response stReader.ReadToEnd()
Catch ex As Exception
MsgBox(ex.Message)
End Try
Return response