übergabe von Anmeldeinformationen in PHP-cURL-Hilfe

Ich versuche mich zu übergeben der Anmeldeinformationen für eine website, so kann ich mit file_get_contents auf Sie zu extrahieren einige Daten, aber es funktioniert nicht, ich erhalte eine leere Seite, also keine Ahnung, was ist hier falsch?

<?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;
?>

Hier ist der neue code ist es immer noch nicht funktioniert, stecken im login screen, wenn ich nicht bekommen, Inhalt....übergabe von Anmeldeinformationen in PHP-cURL-Hilfe

<?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');
?>

Neuen code: ich weiß $url ist die URL, für die ich mich anmelden muss, aber was mache ich in $data? Ich weiß, es ist meine login-info, aber wie mache ich es (z.B., <username> Raum <Passwort>)?

<?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;
}
Was tun, den HTTP-Antwort-Header Aussehen? Welche status haben Sie wieder von dem server?

InformationsquelleAutor Bulvak | 2011-06-08

Schreibe einen Kommentar