submitting xml data using post method but its giving following error
ASP 500 Error
An error occurred processing the page you requested.
Please see the details below for more information.
COM Error Number -2146827864 (0x800A01A8)
File Name /vm/VM_jeune/includes/partenaires_calcul_primes.asp
Line Number 110
Brief Description Object required: 'objDOMXPCML.selectSingleNode(...)'
<?php
/*
Online PHP Examples with Source Code
website: http://4evertutorials.blogspot.in/
*/
$xml_data ='<aatavailreq1>'.
'<agency>'.
'<iata>1234567890</iata>'.
'<agent>lgsoftwares</agent>'.
'<password>mypassword</password>'.
'<brand>phpmind.com</brand>'.
'</agency>'.
'<passengers>'.
'<adult age="" id="1"></adult>'.
'<adult age="" id="2"></adult>'.
'</passengers>'.
'<hotelavailreq1>'.
'<destcode>JHM</destcode>'.
'<hotelcode>OGGSHE</hotelcode>'.
'<checkindate>101009</checkindate>'.
'<checkoutdate>101509</checkoutdate>'.
'<usefield>1</usefield>'.
'</hotelavailreq1>'.
'</aatavailreq1>';
$URL = "http://www.example.com/vm/makessense/calcul_primes.asp";
$ch = curl_init($URL);
// curl_setopt($ch, CURLOPT_MUTE, 1);
curl_setopt($ch, CURLOPT_URL, $URL );
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
curl_setopt($ch, CURLOPT_POSTFIELDS, "$xml_data");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
print_r($output);
?>
its giving 500 error not accepting any data please tell me what is the error in this code.
An error 500 means that the program receiving the XML file has crashed. We can see that it has a bug because it isn't handling the error condition gracefully, but we can't see what that bug is, nor how it is affected by your input data because the ASP crash message has insufficient information to work it out.
So the basic answer to your question is: We don't know, and we can't tell. The only people who could tell you what the problem is would be the owners of the site that has crashed.
You could use a tool like Fiddler to examine the HTTP traffic. This will help you to prove that your code is sending the XML string correctly. You could also use an XML validation tool to prove that the XML is valid.
But if those tests prove that it's okay at your end (and I suspect they will), then there's nothing much else you can do other than ask the people receiving the XML what's wrong with their software and how you can resolve the problem; it may need a code fix on their side, or they may be able to help you work around the issue. Either way, there's nothing we can do here to help you with it.
Related
I am trying to use curl and php to send a file from my liquid web server to the bullhorn vms system. I have tried multiple ways to get this to work but the current code i am using is:
$url_path_str = 'https://rest91.bullhornstaffing.com/rest-services/(corp token)/file/Candidate/'.$entityid.'/raw?filetype=SAMPLE&externalID=portfolio?BhRestToken='.$bhresttoken;
$file_path_str = '/home/path/'.$row["first_name"].$row["last_name"].'.pdf';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, ''.$url_path_str.'');
curl_setopt($ch, CURLOPT_PUT, 1);
$fh_res = fopen($file_path_str, 'r');
curl_setopt($ch, CURLOPT_INFILE, $fh_res);
curl_setopt($ch, CURLOPT_INFILESIZE, filesize($file_path_str));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$curl_response_res = curl_exec ($ch);
echo $url_path_str;
echo $curl_response_res;
curl_close($ch);
fclose($fh_res);
The $entityid, $bhresttoken, $row["first_name"], and $row["last_name"] are variables I have created and using echo shows that they are working. Two errors show up separately when I try to execute this code.
The first error is
"{"errorMessage":"Missing 'BhRestToken' in request header or parameter.","errorMessageKey":"errors.authentication.missingRestToken","errorCode":412}"
which is weird because the bhresttoken allegedly isn't required but also it is definitely showing correctly at the end of the "url_path_str", so is it in the wrong spot?
The other issue that I get is
"An error occurred while processing your request. Reference #179.24343217.1582146766.1f0b67".
From what I've been told the reference number is a generic issue so I'm guessing that my code is flawed somewhere however I cannot figure out what is wrong.
Any advice or input would be much appreciated. Thank you in advance.
I've done every bit of tips and answers but I can't seem to find the right solution.
my cURL is as follows
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $curlIP."api/sparts/search/");
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, "key=".$q."&page=".$pg);
curl_setopt($curl, CURLOPT_FAILONERROR, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$data = curl_exec($curl);
curl_close ($curl);
What does this do?
It gets products data from a server where $q is the search key and $pg is the page number
This cURL works as intended assuming the server will always have an internet connection. As the developer we needed to have an error message whenever the cURL cannot connect to the server.
What is the problem?
For me to actually set an error message I need to know first if the error has happened. This where it gets weird for me. I tried to simulate connection failure by disabling the internet adapter of the server.
The result is:
the page stops parsing everything after the $data = curl_exec($curl);This includes the footer and everything after that line. I knew it because I tried to put echoes before and after curl_exec and it really stops there. therefore I cannot catch the error itself.
What have I tried?
I tried
PHP curl_error() - which didn't really help since the script stops at curl_exec
PHP curl_errno() - same
try and catch - This should have catch the error but it didn't which frustrates me even more.
I have been searching for a way to proxy a mjpeg stream from the AXIS M1114 Network Camera.
using the following url setup
http://host:port/axis-cgi/mjpg/video.cgi?resolution=320x240&camera=1
i try to capture the output and make them available to users with a php script running an apache server on ubuntu.
having browsed the web looking for an answer to no avail i come to you.
my ultimate goal is to have users able to link to the proxy like this:
<img src='proxy.php'>
and have the details of all the things in proxy.php.
I have tried using the way of cURL (advised in similar thread here) but i can't get it to work, probably due to lack of knowledge on the inner workings.
currently my very simple proxy.php looks like this
<?php
$camurl = "http://ip:port";
$campath = "axis-cgi/mjpg/video.cgi";
$userpass = "user:pw";
$ch = curl_init();
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_URL, $camurl + $campath);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'resolution=320x240&camera=1');
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_USERPWD, $userpass);
$result = curl_exec($ch);
header('Content-type: image/jpeg');
echo $result;
curl_close($ch);
?>
My understanding is that this would produce an acceptable output for my plan. But alas.
My question would be if there is a blatant error i do not see. Any simpler option/way of getting the result i aim for is welcome too.
Please point me in the right direction. I happily provide any relevant information i might have missed to provide. Thank you in advance.
solved edit:
After commenting out:
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, true);
changing
curl_setopt($ch, CURLOPT_URL, $camurl + $campath);
to
curl_setopt($ch, CURLOPT_URL, $camurl . $campath); (mixing up some languages)
and most importantly removing a space in the .php file so that the header is actually the header it sort of does what i wanted.
Adding a
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
seems to be needed to get the image displayed as image and not as raw data.
I've been through hell and high water with this problem. I get a 500 error on a page a tiny, tiny fraction of the time. I have been completely unable to reproduce it, but Google insists that they see a 500 code. Fetch as Googlebot says it's successful, however something is wrong. I've been down many avenues and the only recourse I have left is to brute-force the local copy of the website.
I want to use curl to hammer the dev site until I get a 500 error, and when I do, to output the body of the page to the terminal so I can actually get some useful information.
for(;;){
$url = "http://www.blahblah.dev/";
$ch = curl_init();
//Set the URL
curl_setopt($ch, CURLOPT_URL, $url);
//Enable curl response
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//Enable POST data
curl_setopt($ch, CURLOPT_POST, true);
//Use the $pData array as the POST data
curl_setopt($ch, CURLOPT_POSTFIELDS, $jData);
$result = curl_exec($ch);
if(strstr($result, "error")){
echo $result;
exit();
}
curl_close($ch);
usleep(500000);
}
As you can see, I'm simply checking to see if "error" appears in the body, as I can't figure out how to check for a 500 error properly. I realize that this is a terrible and contrived way of debugging, but it's all I've got at this point. Thanks!
I am still fairly new at playing with PHP. I wanted to poke at a small project. I have the ability to access an xml feed from our calendar system at work. The feed requires authentication with a username and password. I am trying to automate pulling this feed. My hope is to one day use it to automate the scheduling of another system but for now I'm just trying to get this side working.
I have read through some of the cURL documentation on php.net. I have also searched through stackoverflow for a few examples. They were helpful in getting me started but not much further. Below is what I have so far. But all I get back is:
UNAUTHORIZED The request requires
authorization
So I'm racking my head to figure out what might be the issue. Part of my problem I'm sure is my ignorance with the actual process behind what is going on between the client and server. When I interact with it normally I just go to the feed URL, the browser prompts me for a username and password, and then after putting that in it gives me an xml page.
I've checked for most of the formatting errors and syntax errors I knew to look for. That may still be it but at this point I think it's more my lack of understanding how it all fits together. Thanks for any help.
Similar issues:
Parsing XML data with Namespaces in PHP
CURL HTTP Authentication at server side
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://somesight.someplace.edu/r25ws/servlet/wrd/run/events.xml");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERPWD, "username:password");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));
curl_setopt($ch, CURLOPT_UNRESTRICTED_AUTH, 1);
$output = curl_exec($ch);
curl_close($ch);
echo $output;
?>
I figured it out on my own after looking at a similar tutorial for Twitter. I tried a different approach to formatting the options and it worked fine. I also cut down on the number of options I was sending because it seemed like overkill. Code that works below.
<?php
$username = 'myusername';
$password = 'mypassword';
$datecall = curl_init("http://somesite.someplace.edu/r25ws/servlet/wrd/run/events.xml");
curl_setopt($datecall, CURLOPT_USERPWD, $username.":".$password);
curl_setopt($datecall, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($datecall);
echo $result;
?>