我正在尝试使用cURL将我的xml文件作为PARAM发送时,找出我完成的URL的样子。但是,我没有看到cURL为我发送到我的apache tomcat服务器上的java servlet所创建的内容。
任何帮助/方向将不胜感激。谢谢。
以下是我的规格:
我的$ data:
object(SimpleXMLElement)#1 (5) {
["version"]=>
string(3) "2.0"
["orderNo"]=>
string(37) "sfly.000020513524-7001536_28935-tb.33"
["orderDate"]=>
string(23) "2012-09-21 09:52:53 PDT"
["processing"]=>
object(SimpleXMLElement)#2 (1) {
["statusCallback"]=>
string(79) "http://orderfulfillment.shutterfly.com/ogateway-test/status/sfly/xpressdocs/
"
}
["suborders"]=>
object(SimpleXMLElement)#3 (1) {
["suborder"]=>
object(SimpleXMLElement)#4 (7) {
["suborderNo"]=>
string(5) "51917"
["deliveryEstimate"]=>
object(SimpleXMLElement)#5 (2) {
["earliest"]=>
string(23) "2012-10-01 00:00:00 PDT"
["latest"]=>
string(23) "2012-10-05 00:00:00 PDT"
}
["greeting"]=>
object(SimpleXMLElement)#6 (2) {
["line1"]=>
string(45) "Ordered for you by Andrew Mullen on 09/21/12."
["line2"]=>
string(61) "Save 20% on Holiday Cards November 20 - 30 at Shutterfly
"
}
["shipAddr"]=>
object(SimpleXMLElement)#7 (8) {
["name"]=>
string(12) "burkina faso"
["address1"]=>
string(17) "1234 burkina road"
["address2"]=>
object(SimpleXMLElement)#9 (0) {
}
["city"]=>
string(4) "yako"
["region"]=>
string(3) "R21"
["postCode"]=>
object(SimpleXMLElement)#10 (0) {
}
["countryCode"]=>
string(2) "BF"
["countryName"]=>
string(12) "Burkina Faso"
}
["shipMethod"]=>
string(7) "INTLSTD"
["additionalFulfillers"]=>
string(5) "false"
["items"]=>
object(SimpleXMLElement)#8 (1) {
["item"]=>
object(SimpleXMLElement)#11 (6) {
["itemNo"]=>
string(2) "36"
["sku"]=>
string(13) "6X8FLATCARD06"
["description"]=>
string(39) "6x8 Stationery Card - Stacy Claire Boyd"
["quantity"]=>
string(1) "1"
["product"]=>
object(SimpleXMLElement)#12 (1) {
["stationery"]=>
object(SimpleXMLElement)#14 (6) {
["formFactor"]=>
string(3) "6x8"
["paperFinish"]=>
string(5) "MATTE"
["orientation"]=>
string(9) "LANDSCAPE"
["image"]=>
object(SimpleXMLElement)#15 (1) {
["location"]=>
string(130) "http://orderfulfillment.shutterfly.com/fulfillment-test/image/1200/000020513524-7001536_28935--164044--315625--canvas.jpg
"
}
["boc"]=>
object(SimpleXMLElement)#16 (1) {
["location"]=>
string(130) "http://orderfulfillment.shutterfly.com/fulfillment-test/image/1200/000020513524-7001536_28935--164044--315626--canvas.jpg
"
}
["copyright"]=>
object(SimpleXMLElement)#17 (1) {
["text"]=>
string(13) "6X8FLATCARD06"
}
}
}
["envelopes"]=>
object(SimpleXMLElement)#13 (1) {
["envelope"]=>
object(SimpleXMLElement)#18 (2) {
["toAddress"]=>
object(SimpleXMLElement)#19 (10) {
["font"]=>
object(SimpleXMLElement)#21 (2) {
["fontName"]=>
string(5) "Arial"
["fontSize"]=>
string(2) "12"
}
["name"]=>
string(10) "FPO Tester"
["companyTitle"]=>
object(SimpleXMLElement)#22 (0) {
}
["address1"]=>
string(16) "PSC 812 Box 2640"
["address2"]=>
object(SimpleXMLElement)#23 (0) {
}
["city"]=>
string(3) "FPO"
["region"]=>
string(2) "AE"
["postCode"]=>
string(5) "09627"
["countryCode"]=>
string(3) "USA"
["countryName"]=>
string(24) "United States of America"
}
["fromAddress"]=>
object(SimpleXMLElement)#20 (10) {
["font"]=>
object(SimpleXMLElement)#24 (2) {
["fontName"]=>
string(5) "Arial"
["fontSize"]=>
string(2) "12"
}
["name"]=>
string(13) "Andrew Mullen"
["companyTitle"]=>
object(SimpleXMLElement)#25 (0) {
}
["address1"]=>
string(22) "2333 W. El Moro Circle"
["address2"]=>
object(SimpleXMLElement)#26 (0) {
}
["city"]=>
string(4) "Mesa"
["region"]=>
string(2) "AZ"
["postCode"]=>
string(5) "85202"
["countryCode"]=>
string(3) "USA"
["countryName"]=>
string(24) "United States of America"
}
}
}
}
}
}
}
}
我的$ url ='http://melinda.xpressdocs.com/PostHandler';
这是我的代码:
function postToUrl($url, $data) {
$post = curl_init();
curl_setopt($post, CURLOPT_URL, $url);
curl_setopt($post, CURLOPT_POST, 1);
curl_setopt($post, CURLOPT_POSTFIELDS, $data);
curl_setopt($post, CURLOPT_RETURNTRANSFER, 1);
$value = curl_getinfo($post);
var_dump($value);
exit;
$result = curl_exec($post);
curl_close($post);
}
var_dump的结果:
array(20) {
["url"]=>
string(42) "http://melinda.xpressdocs.com/PostHandler/"
["content_type"]=>
NULL
["http_code"]=>
int(0)
["header_size"]=>
int(0)
["request_size"]=>
int(0)
["filetime"]=>
int(0)
["ssl_verify_result"]=>
int(0)
["redirect_count"]=>
int(0)
["total_time"]=>
float(0)
["namelookup_time"]=>
float(0)
["connect_time"]=>
float(0)
["pretransfer_time"]=>
float(0)
["size_upload"]=>
float(0)
["size_download"]=>
float(0)
["speed_download"]=>
float(0)
["speed_upload"]=>
float(0)
["download_content_length"]=>
float(-1)
["upload_content_length"]=>
float(-1)
["starttransfer_time"]=>
float(0)
["redirect_time"]=>
float(0)
}
答案 0 :(得分:0)
将 CURLOPT_VERBOSE 设置为true以查看cURL正在执行的操作