$file = file_get_contents($path, true);
$url = "https://secure.efaxdeveloper.com/EFax_WebFax.serv";
//setting the curl parameters.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/x-www-form-urlencoded',
));
// Following line is compulsary to add as it is:
$data = 'id=' . urlencode("2313125942") . '&name2=' . urlencode($file);
curl_setopt($ch, CURLOPT_POSTFIELDS,$data);
$data = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
print_r('<pre>');
print_r($info);
print_r('</pre>');
In meinem Code oben stelle ich die Content-Type: application/x-www-form-urlencoded
und Post-DatenLocken content_type immer die Standard PHP
$data = 'id=' . urlencode("2313125942") . '&name2=' . urlencode($file);
curl_setopt($ch, CURLOPT_POSTFIELDS,$data);
Aber das Ergebnis der curl_getinfo()
Array
(
[url] => https://secure.efaxdeveloper.com/EFax_WebFax.serv
[content_type] => text/html;charset=ISO-8859-1
[http_code] => 200
[header_size] => 226
[request_size] => 175
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0.65944
[namelookup_time] => 0.150319
[connect_time] => 0.183032
[pretransfer_time] => 0.261438
[size_upload] => 531848
[size_download] => 833
[speed_download] => 1263
[speed_upload] => 806514
[download_content_length] => 833
[upload_content_length] => 531848
[starttransfer_time] => 0.293966
[redirect_time] => 0
[redirect_url] =>
[primary_ip] => 104.12.131.61
[certinfo] => Array
(
)
[primary_port] => 443
[local_ip] => 127.31.12.152
[local_port] => 52972
)
Meine Frage, warum content_type ist ist [content_type] => text/html; charset = ISO-8859-1 und ich kann die Post-Daten nicht sehen. Ich bin ein Anfänger in Curl kann jemand erklären, was in meinem Code falsch ist?
Der 'content-type' von' curl_getinfo' ist der Inhaltstyp der Antwort, nicht die Anfrage. Dies bedeutet, dass sie als Antwort auf Ihre HTTP-Anfrage eine HTML-Webseite zurücksenden. Weitere Informationen zu Ihrer Anfrage finden Sie unter 'CURLOPT_VERBOSE' unter http://php.net/curl_setopt. CURL legt außerdem automatisch den Inhaltstyp der Anfrage für Sie fest, sodass Sie ihn nicht angeben müssen, es sei denn, Sie müssen ihn explizit überschreiben. – drew010
Ich möchte alle Informationen über meine Anfrage sehen i dachte curl_getinfo() Funktion wird dies danken Ihnen für diese Information. – Jay
Ich habe versucht, die curl_setopt ($ ch, CURLOPT_VERBOSE, true) Wie kann ich die Informationen meiner Anfrage ausdrucken? – Jay