Hi,
I would like to post some values (for example boolean) from a php file to my Java Servlet.
It is basically a notification system which i am trying to implement.The functionality is that a user posts a question to a website (built using php) and when ever he gets an answer to his question,i should be able to pass a boolean value from my php file to java servlet.
The php function i am using for this to work is
function do_post_request($url, $data, $optional_headers = null) {
$params = array('http' => array(
'method' => 'POST',
'content' => $data
));
if ($optional_headers!== null) {
$params['http']['header'] = $optional_headers;
}
$ctx = stream_context_create($params);
$fp = fopen($url, 'rb', false, $ctx);
if (!$fp) {
**echo '<br>echo in if statement <br>';**
throw new Exception("Problem with $url, $php_errormsg");
}
$response = @stream_get_contents($fp);
if ($response === false) {
throw new Exception("Problem reading data from $url, $php_errormsg");
}
return $response;
}
And this method always echoes "echo in if statement".That means the value of fp is null AND that means to me that the URL i provided is wrong.
But the URL which i provided is basically a java servlet and i can open it in my web browser.
So can anyone help me on this.
i would request a detailed explanation of any php code modifications suggested as i am new to php.Also please let me know incase i need to provide extra information about this question
Thanks