首先,curl_init
不够。您需要使用curl_exec
实际发送请求。发送请求后,您可以使用curl_errno
来检查是否返回错误,并使用curl_getinfo
来获取有关请求和响应的更多信息,例如HTTP响应代码(例如:200,404),连接所花费的时间等。
从curl_getinfo
文档修改例如:
<?php
// Create a curl handle
$ch = curl_init('http://v970032.y5pgm9yfhypo.demo17.volusion.com/net/[email protected]&EncryptedPassword=24EA69124482A486AF3E6BA68DDEECBB7CBC3661EA792E0DC4A40CD6FC031E6E&Import=Update');
// Tell cURL to return the transfer instead of outputting it.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Execute
$result = curl_exec($ch);
// Check if any error occured
if (!curl_errno($ch)) {
// Here, I'm outputting the value of $result but you can do whatever you'd like
// with it such as using a DOMDocument to parse XML or HTML, json_decode to
// parse JSON, etc.
echo $result;
} else {
echo 'Sorry, an error occurred while connecting to Volusion.';
}
// Close handle
curl_close($ch);
取决于你想要做什么,你可能想在curl_setopt
在CURLOPT_RETURNTRANSFER
和一些其他的看看,更具体基本选项,你可以传递给卷曲。这些选项是有据可查的。
感谢您的回复。只使用URL我得到了解决方案,但实际上我使用登录ID和密码连接到volusion商店。我想检查URL是否正确连接。它不仅域名,但它也有一些参数附加到URL – Sneha 2012-03-26 07:07:55
@ user1292325 - 我不认为我明白你要问的东西,因为我会再次给你完全相同的答案。所以你想要做的是非常的URL是有效的,它包含某些查询字符串参数之前做cURL请求? – 2012-03-26 07:09:01
是的我有一定的查询字符串参数,将连接到volusion商店时用作登录凭证 – Sneha 2012-03-26 07:15:50