Bonjour,
Je bloque pour trouver une solution a mon problème.
Je cherche une solution pour envoyer des données sur le site web 2 et recevoir la réponse.
Avec le code plus bas, cela fonctionne mais mon souhait est de recevoir la réponse du site web 2 sans faire un "echo" sur celui-ci.
J'ai lu sur le net qu'il faut utiliser stream_context_create mais je ne trouve aucun exemple concret, sûrement que j'ai mal compris.
Ma question est: Est-il possible de recevoir la réponse du site web 2 sans faire un echo/print?


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
 
	print_r(get_blacklist_content($url));
	function get_blacklist_content($url) {
		$context = stream_context_create(
		array(
		"http" => array(
		"header" => "User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36"
		)
		)
		);
		$url="https://www.site2.fr/getseo.php?key=AAAAA&pass=bbbbbb";
 
		//$post_value="LOOKUPADDRESS=";
		$ch = curl_init(); 
		curl_setopt($ch, CURLOPT_USERAGENT, $context);
		curl_setopt($ch, CURLOPT_AUTOREFERER, true);
		curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 7);
		curl_setopt($ch, CURLOPT_REFERER, 'http://'.$url);
		curl_setopt($ch, CURLOPT_URL, $url); 
		curl_setopt($ch, CURLOPT_FAILONERROR, 1);
		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
		curl_setopt($ch, CURLOPT_TIMEOUT, 120); 
		curl_setopt($ch, CURLOPT_POST, 1); 
		//curl_setopt($ch, CURLOPT_POSTFIELDS, $post_value); 
		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
		$content = curl_exec($ch); // run the whole process
		curl_close($ch);
		return $content;
	}
Merci d'avance.