我试图通过url传递get变量来生成xml数据,传递变量并使用curl获取xml数据并将其恢复到网页,这样我就可以解析数据并使用其中一个元素属性值并将其放入php变量中以显示在页面上。
所以我似乎永远都是这样,但我有以下代码,(fyi。我输入密码'代替真正的密码。'托运人号码在这里代替真实的托运人编号和代币,代替此线程的真实代币)
$xml = '
weight_system="IMPERIAL" shipper_number="shipper number in here" destination_postal_code="'.$data5['zip'].'" service_type="1"
';
$xml2 = '
total_pieces="'.$value.'" total_weight="'.$weight.'"
';
$token = 'token here';
$base_url = 'https://www.shippingco.com/XML/RatingXML.jsp';
$request_url = $base_url . '?' . http_build_query(array(
'shipment' => '<shipment ' . $xml . '><total ' . $xml2 . '/></shipment>',
'token' => $token
));
// Get cURL resource
$curl = curl_init();
// Set some options - we are passing in a useragent too here
curl_setopt($curl, CURLOPT_URL, $request_url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER,1);
curl_setopt($curl, CURLOPT_VERBOSE, '1');
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, '1');
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, '1');
curl_setopt($curl, CURLOPT_CAINFO, '../cert/ca.crt');
curl_setopt($curl, CURLOPT_SSLCERT, '../cert/mycert.pem');
curl_setopt($curl, CURLOPT_SSLKEY, '../cert/mykey.pem');
curl_setopt($curl, CURLOPT_SSLCERTPASSWD, 'password');
// Send the request & save response to $resp
$result = curl_exec($curl);
echo curl_error($curl);
// Close request to clear up some resources
curl_close($curl);
产生:
error: unable to use client certificate (no key found or wrong pass phrase?)
我尝试使用getcwd()调用路径。&#39; ../ cert /... 39;,getcwd()。&#39; / cert /...& #39;,&#39; public_html / cert /... 39;并使用此代码检查路径是否有效,
if (file_exists('../cert/ca.crt')) {
echo 'yes';
} else {
echo 'no';
}
和file_exists在调用../cert/ca.crt时返回yes,所以我在curl代码中使用该路径。但我还是不确定还有什么问题。
我购买了一个SSL和专用的IP地址,这让你感到疑惑。我有RSA密钥,SSL证书,CA捆绑和密码,我将它们保存为上面列出的名为cert的文件名和格式。如果我将它们保存为错误的文件格式或错误的扩展名,请告诉我。谢谢你的时间。
目录结构:
public_html (root)
cert (dir inside public_html)
ca.crt (file inside cert)
mycert.pem (file inside cert)
mykey.pem (file inside cert)
secure (dir inside public_html)
shopping.php (file inside secure)