Bonjour,
J'utilise la methode sendToHost pour envoyer des trucs à des URLs en POST et en GET, voici le code de la methode :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/////////////////////////////////
	/* sendToHost
	* ~~~~~~~~~~
	* Params:
	*   $host - Just the hostname.  No http:// or /path/to/file.html portions
	*   $port - default to 80
	*   $method - get or post, case-insensitive
	*   $path - The /path/to/file.html part
	*   $data - The query string, without initial question mark
	*
	* Examples:
	*   sendToHost('www.google.com',80,'get','/search','q=php_imlib');
	*   sendToHost('www.example.com',80,'post','/some_script.cgi',
	*              'param=First+Param&second=Second+param');
	*/
	private function sendToHost($host,$port=80,$method,$path,$data) {
		$buf = '';
 
		if (empty($method)) $method = 'GET';
		$method = strtoupper($method);
		if ($method == 'GET') $path .= '?' . $data;
 
		$fp = fsockopen($host,$port);
 
		if ($fp) {
			fputs($fp, "$method $path HTTP/1.1\r\n");
			fputs($fp, "Host: $host\r\n");
			fputs($fp, "Content-Type: application/x-www-form-urlencoded\r\n");
			if ($method == 'POST') fputs($fp, "Content-length: " . strlen($data) . "\r\n");
			fputs($fp, "Connection: close\r\n\r\n");
			if ($method == 'POST') fputs($fp, $data);
 
			$buf = '';
			while (!feof($fp))
			$buf .= fgets($fp,128);
			fclose($fp);
		}
 
		return $buf;
	}
ca fonctionne avec une ouverture de socket à bas niveau (plus ou moins ) avec fsockopen, l'action d'envoie prends un peux de temps et ca commence à gener lorsque je voudrais faire des requetes massives.
J'ai bien chercher à remplacer celle la, j'hésite entre utilise CURL et file_get_contents sachant que cette derniére ne transfére pas de requetes en POST, mais ca reste possible de combiner les deux (GET en file_get_contents et POST en autres).
C'est les deux autres methodes que je connais, dites moi si y'en à d'autres, sinon mon probléme c'est chercher la meilleur methode en terme de vitesse d'envoi (mon objectif c'est d'atteindre un grand flux d'envoi).
Merci pour votre aide.