我試圖使用curl將圖像和更多選項發送到服務器,但我不知道爲什麼它不起作用。這裏是代碼:發送表單到https
<?php
header('Location: https://www.reporo.com/analytics/inventory-advertiser-banner.php?clientid=xxxx&campaignid=xxxx&type=smrc');
$uploadUrl = "C:\wamp\www\autofill\demo_300x250.png";
$uploadUrl = "@$uploadUrl";
$post_data['description'] = 'Name';
$post_data['url'] = 'http://www.url.pl';
$post_data['campaignid'] = xxxxx;
$post_data['clientid'] = xxxxx;
$post_data['bannertext'] = 'some text';
$post_data['upload_smrc'] = $uploadUrl;
foreach ($post_data as $key => $value)
{
$post_items[] = urlencode($key) . '=' . urlencode($value);
}
$post_string = implode ('&', $post_items);
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $post_string);
curl_setopt ($ch, CURLOPT_REFERER, "https://www.reporo.com/analytics/inventory-advertiser-banner.php?clientid=xxxxx&campaignid=xxxxx&type=smrc");
curl_setopt ($ch, CURLOPT_URL, 'https://www.reporo.com/analytics/inventory-advertiser-banner-update.php');
$upload_result = curl_exec ($ch);
curl_close ($ch);
?>
$ post_data中的索引是正確的。該表單與CURLOPT_REFERER處於同一鏈接。現場行動我形式包含:inventory-advertiser-banner-update.php。
此外,我無法使用curl登錄到此網站,但是當我之前登錄時,重定向工作,因此它應該工作。
這個網站的網站可能無法使用捲曲嗎?我問,因爲之前我有問題登錄,我沒有解決,現在這個。
也許有辦法解決?
問候。
你得到的捲曲錯誤是什麼。可能是由於安全證書問題。見http://stackoverflow.com/questions/521418/reading-ssl-page-with-curl-php和http://unitstep.net/blog/2009/05/05/using-curl-in-php-to -access-https-ssltls-protected-sites/ –
沒有捲曲錯誤;/ –