transmission des informations d'identification en PHP cURL aider

Je suis en train de transmettre des informations d'identification d'un site web afin que je puisse utiliser file_get_contents sur elle pour en extraire des données, mais il ne fonctionne pas, j'obtiens une page blanche donc aucune idée de ce qu'est le problème ici?

<?php


$username="[email protected]";
$password="Koin";

$url="confluence.rogersdigitalmedia.com";


$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
$output = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);

$str= file_get_contents("confluence.rogersdigitalmedia.com/display/prodsupport/Team+Calendar");
echo $str;
?>

Voici le nouveau code, il n'y a toujours pas collé à l'écran de connexion quand je fais des matières....transmission des informations d'identification en PHP cURL aider

<?php
$username="[email protected]";
$password="Koin";

$url="confluence.rogersdigitalmedia.com";


$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);


//Replaced due to special chars in url for username and pass
//curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_USERPWD, urlencode($username) . ':' . urlencode($password));
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
$output = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);

echo file_get_contents('http://confluence.rogersdigitalmedia.com/exportword?pageId=1114407');
?>

Nouveau code: je sais $url est l'URL que j'ai à l'ouverture, mais que dois-je mettre dans $data? Je sais que c'est mon login info, mais comment dois-je les mettre (par exemple, <username> espace <mot de passe>)?

<?php
function do_post_request($url, $data, $optional_headers = null)
{
  $params = array('http' => array(
              'method' => 'POST',
              'content' => $data
            ));
  if ($optional_headers !== null) {
    $params['http']['header'] = $optional_headers;
  }
  $ctx = stream_context_create($params);
  $fp = @fopen($url, 'rb', false, $ctx);
  if (!$fp) {
    throw new Exception("Problem with $url, $php_errormsg");
  }
  $response = @stream_get_contents($fp);
  if ($response === false) {
    throw new Exception("Problem reading data from $url, $php_errormsg");
  }
  return $response;
}
Ce qui ne l'-têtes de Réponse HTTP ressembler? Quel est le statut que vous obtenez en retour du serveur?

OriginalL'auteur Bulvak | 2011-06-08