Retourner au contenu associé (entrée de forum : GET et POST en php ?)
Posté par Narmer le 04 mai 2005 à 18:51. En réponse au message GET et POST en php ?. Évalué à 2.
<? $URL="www.mysite.com/test.php"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,"https://$URL(...)"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, "Data1=blah&Data2=blah");curl_exec ($ch); curl_close ($ch); ?>
<? // Generate the request header $ReqHeader = "POST $URI HTTP/1.1\n". "Host: $Host\n". "Content-Type: application/x-www-form-urlencoded\n". "Content-Length: $ContentLength\n\n". "$ReqBody\n"; // Open the connection to the host $socket = fsockopen($Host, 80, &$errno, &$errstr); if (!$socket) $Result["errno"] = $errno; $Result["errstr"] = $errstr; return $Result; } $idx = 0; fputs($socket, $ReqHeader); while (!feof($socket)) $Result[$idx++] = fgets($socket, 128); } //------------------------------------------- ?>
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
[^] # Re: fsockopen
Posté par Narmer . En réponse au message GET et POST en php ?. Évalué à 2.
j'ai un peu cherché et cette à cette URL http://www.alt-php-faq.org/local/55/#id55(...) ils disent que l'utilisation de cURL (http://curl.haxx.se)(...) est aisée mais il faut que ton hebergeur l'aie compilé dans php.
J'ai vérifié avec un petit phpinfio et mon hébergeur l'a bien :>
je vais pouvoir faire ce genre de choses
c est mieux que ;)
plus d'info là http://curl.haxx.se/libcurl/php/(...)