本文整理汇总了PHP中CopixUrl::valueToUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP CopixUrl::valueToUrl方法的具体用法?PHP CopixUrl::valueToUrl怎么用?PHP CopixUrl::valueToUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CopixUrl
的用法示例。
在下文中一共展示了CopixUrl::valueToUrl方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _launchRequest
/**
* Lancement d'une requête
*
* @param CopixHTTPClientRequest $pRequest
* @return unknown
*/
private function _launchRequest(CopixHTTPClientRequest $pRequest)
{
if (CopixConfig::get('default|proxyEnabled')) {
//proxy_host, proxy_port, proxy_login et proxy_password
curl_setopt($this->_curl, CURLOPT_HTTPPROXYTUNNEL, true);
if (CopixConfig::get('default|proxyHost') != null) {
curl_setopt($this->_curl, CURLOPT_PROXY, str_replace('http://', '', CopixConfig::get('default|proxyHost')));
}
if (CopixConfig::get('default|proxyPort') != null) {
curl_setopt($this->_curl, CURLOPT_PROXYPORT, intval(CopixConfig::get('default|proxyPort')));
}
if (CopixConfig::get('default|proxyUser') != null) {
$proxyUserPass = CopixConfig::get('default|proxyUser');
if (CopixConfig::get('default|proxyPass') != null) {
$proxyUserPass .= ':' . CopixConfig::get('default|proxyPass');
}
curl_setopt($this->_curl, CURLOPT_PROXYUSERPWD, $proxyUserPass);
}
}
curl_setopt($this->_curl, CURLOPT_TIMEOUT, $pRequest->getTimeout());
// Choix de l'interface à utiliser
$interfaceUsed = $pRequest->getInterface();
// Si pas d'interface on récupère celle en configuration
if ($interfaceUsed !== '') {
$interfaceUsed = CopixConfig::get('default|webservicesInterface');
}
// Mise en place de l'interface
if (isset($interfaceUsed)) {
curl_setopt($this->_curl, CURLOPT_INTERFACE, $interfaceUsed);
}
if ($pRequest->getIgnoreCertificate()) {
curl_setopt($this->_curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($this->_curl, CURLOPT_SSL_VERIFYHOST, false);
}
curl_setopt($this->_curl, CURLOPT_URL, $pRequest->getUrl());
curl_setopt($this->_curl, CURLOPT_VERBOSE, 1);
if ($pRequest->getHeader()) {
curl_setopt($this->_curl, CURLOPT_HTTPHEADER, $pRequest->getHeader());
}
if ($pRequest->getCookie()) {
curl_setopt($this->_curl, CURLOPT_COOKIE, $pRequest->getCookie());
}
if (count($pRequest->getPost())) {
if ($pRequest->getFile()) {
$boundary = uniqid('------------------');
$MPboundary = '--' . $boundary;
$endMPboundary = $MPboundary . '--';
$postBody = 'Content-type: multipart/form-data, boundary=' . $boundary . "\r\n\r\n";
foreach ($pRequest->getPost() as $name => $content) {
$postBody .= $MPboundary . "\r\n";
$postBody .= 'content-disposition: form-data; name="' . $name . '"' . "\r\n\r\n";
$postBody .= $content . "\r\n";
}
$file = $pRequest->getFile();
$fileContent = file_get_contents($file);
$postBody .= $MPboundary . "\r\n";
$postBody .= 'Content-Disposition: form-data; name="file"; filename="' . basename($file) . '"' . "\r\n";
$postBody .= 'Content-Type: ' . CopixMIMETypes::getFromFileName($file) . "\r\n";
$postBody .= 'Content-Transfer-Encoding: binary' . "\r\n\r\n";
$postBody .= $fileContent;
$postBody .= "\r\n" . $endMPboundary;
curl_setopt($this->_curl, CURLOPT_POST, true);
curl_setopt($this->_curl, CURLOPT_POSTFIELDS, $postBody);
curl_setopt($this->_curl, CURLOPT_HTTPHEADER, array("Content-Type: multipart/form-data; boundary={$boundary}"));
curl_setopt($this->_curl, CURLOPT_RETURNTRANSFER, true);
} else {
curl_setopt($this->_curl, CURLOPT_POST, true);
curl_setopt($this->_curl, CURLOPT_POSTFIELDS, CopixUrl::valueToUrl(null, $pRequest->getPost()));
}
}
if ($pRequest->getFollowRedirect()) {
curl_setopt($this->_curl, CURLOPT_FOLLOWLOCATION, 1);
} else {
curl_setopt($this->_curl, CURLOPT_FOLLOWLOCATION, 0);
}
return new CopixHTTPRequestResult($pRequest, $this->_curl);
}
示例2: testValueToUrl
public function testValueToUrl()
{
$this->assertEquals(CopixUrl::valueToUrl('test', array(1, 2, 3, 4)), 'test[0]=1&test[1]=2&test[2]=3&test[3]=4');
$this->assertEquals(CopixUrl::valueToUrl(null, array('test' => array(1, 2, 3, 4))), 'test[0]=1&test[1]=2&test[2]=3&test[3]=4');
$this->assertEquals(CopixUrl::valueToUrl('test', array(1, 2, 3, 4), true), '&test[0]=1&test[1]=2&test[2]=3&test[3]=4');
$this->assertEquals(CopixUrl::valueToUrl(null, array('test' => array(1, 2, 3, 4)), true), '&test[0]=1&test[1]=2&test[2]=3&test[3]=4');
$this->assertEquals(CopixUrl::valueToUrl('test', array(1, 2, 3, 4), true, true), '&test[0]=1&test[1]=2&test[2]=3&test[3]=4');
$this->assertEquals(CopixUrl::valueToUrl(null, array('test' => array(1, 2, 3, 4)), true, true), '&test[0]=1&test[1]=2&test[2]=3&test[3]=4');
}