2011-01-22 3 views
0
boucle

En utilisant Curl j'envoie des données de poste à un server.This est l'en-tête Reponse iam obtenirLire le contenu en utilisant

HTTP/1.1 100 Continuer HTTP/1.1 200 OK Content-Length: 30 Content-Type: text/html; jeu de caractères = ISO-8859-1 Serveur: Microsoft-IIS/7.0 X-Powered-By: Servlet 2.5; JBoss-5.0/JBossWeb-2.1 Set-Cookie: JSESSIONID = XXXXXXXXXXXXXXXXXXXXXXX; Chemin =/thegateway; P3P sécurisé: CP = "CAO PSA OUR" X-Powered-By: ASP.NET Date: Sat, 22 Jan 2011 00:07:25 GMT

Comment puis-je lire le reste du contenu?

Répondre

0

Peut-être avez-vous oublié de définir l'option CURLOPT_RETURNTRANSFER dans l'appel curl? Lorsqu'il est défini, le contenu de la réponse est renvoyé par la fonction curl_exec() elle-même.

Ce code d'un projet de travail de la mine:

$options = array(
      CURLOPT_SSL_VERIFYPEER => false, 

      CURLOPT_RETURNTRANSFER => $this->return_content,  // return web page 
      CURLOPT_HEADER   => false, // don't return headers, they are processed through callback 
      CURLOPT_FOLLOWLOCATION => $this->follow_redirects,  // follow redirects 
      CURLOPT_ENCODING  => "",  // handle all encodings 
      CURLOPT_USERAGENT  => $this->user_agent, // who am i 
      CURLOPT_CONNECTTIMEOUT => $this->connect_timeout,  // timeout on connect 
      CURLOPT_TIMEOUT  => $this->request_timeout,  // timeout on response 
      CURLOPT_BINARYTRANSFER => true, 
      ); 
    $extraheaders = array();    

    $res = curl_init($url); 
    curl_setopt_array($res, $options); 
    $content = curl_exec($res); 
+0

J'ai mis l'option CURLOPT_RETURNTRANSFER à 1, mais seulement obtenir le contenu d'en-tête. – deej

+0

Alors, que retourne la fonction curl_exec? Chaîne vide? – Cray

+0

son retour "HTTP/1.1 100 Continuer HTTP/1.1 200 OK Longueur du contenu: 30 Type de contenu: texte/html; jeu de caractères = ISO-8859-1 Serveur: Microsoft-IIS/7.0 X-Powered-By: Servlet 2.5; JBoss-5.0/JBossWeb-2.1 Ensemble-Cookie: JSESSIONID = XXXXXXXXXXXXXXXXXXXXXXX; Chemin =/thegateway; Sécurisé P3P: CP = "CAO PSA NOTRE" X-Powered-By: ASP.NET Date: Sat, 22 Jan 2011 00:07: 25 GMT " – deej

Questions connexes