我正在使用GoDaddy的终极托管包。该帐户安装了静态 IP 和 SSL。现在,当我尝试使用需要静态IP的API时。但是脚本正在从随机 IP 发送请求。请给我建议一种方法。
我的脚本
$soap_exception_occured = false;
$wsdl_path = 'http://vrapi.sslwireless.com/?wsdl';
$response = '';
ini_set('soap.wsdl_cache_enabled', '0'); // disabling WSDL cache
try {
$client = new SoapClient($wsdl_path);
}
catch(SoapFault $exception) {
$soap_exception_occured = true;
$response .= ''nError occoured when connecting to the SMS SOAP Server!';
$response .= ''nSoap Exception: '.$exception;
}
我正在使用肥皂。IP 绑定可以帮助我吗?
假设您使用 php 的 curl 连接到该 API,您应该将每个请求绑定到您的 IP:
curl_setopt($ch, CURLOPT_INTERFACE, $myIP);
要将 CURL 绑定到不同的传出网络接口或不同的 IP 地址,只需在执行 CURL 请求之前将CURLOPT_INTERFACE设置为适当的值:
试试这个,让我知道发生了什么
$soap_exception_occured = false;
$ipandport = array(
'socket' => array(
'bindto' => 'xx.xx.xx.xx:port',
),
);
$setip = stream_context_create(ipandport);
$wsdl_path = 'http://vrapi.sslwireless.com/?wsdl';
$response = '';
ini_set('soap.wsdl_cache_enabled', '0'); // disabling WSDL cache
try {
$client = new SoapClient($wsdl_path, array('stream_context' => $setip));
}
catch(SoapFault $exception) {
$soap_exception_occured = true;
$response .= ''nError occoured when connecting to the SMS SOAP Server!';
$response .= ''nSoap Exception: '.$exception;
}
如果没有file_get_contents,这个线程将不完整:
$opts = array(
'socket' => array(
'bindto' => 'xx.xx.xx.xx:0',
)
);
$context = stream_context_create($opts);
echo file_get_contents('http://www.example.com', false, $context);