Viewing file: index.php (1.87 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?
echo '<h1>Положение гонщиков на '.$dat.'</h1>'; //Выводим заголовок //Задаем ссылку получения документа $myurl = "https://spreadsheets.google.com/spreadsheet/pub?hl=ru&key=0ArHgbNSjqIoVdHRIR1B0YkdWUDNDclRMTzNBNUJIa2c#&single=true&gid=0&output=html"; // gid - номер страницы; output - тип результата (html/csv) // подключаем curl
$clientlogin_url = "https://www.google.com/accounts/ClientLogin"; $clientlogin_post = array( "accountType" => "HOSTED_OR_GOOGLE", "Email" => "morozov.andriy@gmail.com", "Passwd" => "mmm1048576Morozov", "service" => "writely", "source" => "test" ); $curl = curl_init($clientlogin_url); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, $clientlogin_post); curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $response = curl_exec($curl); preg_match("/Auth=([a-z0-9_\-]+)/i", $response, $matches); $auth = $matches[1]; $headers = array( "Authorization: GoogleLogin auth=" . $auth, "GData-Version: 3.0", ); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_URL, $myurl); curl_setopt($curl, CURLOPT_POST, false); $response = curl_exec($curl); // $response теперь содержит нашу таблицу в формате csv curl_close($curl); // разбиваем по строкам $res = explode("\n",$response); echo '<table>'; foreach($res as $row) { //разбивка на столбики $row = explode(",",$row); echo '<tr>'; echo '<td>'.$row[0].'</td>';//место echo '<td>'.$row[1].'</td>';//имя echo '<td>'.$row[3].'</td>';//страна echo '<td>'.$row[4].'</td>';//рейтинг echo '<td>'.$row[5].'</td>';//за месяц echo '</tr>'; } ?>
|