Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function request($url,$post = 0){
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url ); // отправляем на
- curl_setopt($ch, CURLOPT_HEADER, 0); // пустые заголовки
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // возвратить то что вернул сервер
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // следовать за редиректами
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);// таймаут4
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__).'/cookie.txt'); // сохранять куки в файл
- curl_setopt($ch, CURLOPT_COOKIEFILE, dirname(__FILE__).'/cookie.txt');
- curl_setopt($ch, CURLOPT_POST, $post!==0 ); // использовать данные в post
- if($post)
- curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
- $data = curl_exec($ch);
- curl_close($ch);
- return $data;
- }
- $mdpu_dfn1 = request("http://www.dfn.mdpu.org.ua/login/index.php", array("username"=>"Логин","password"=>"Пароль","anchor"=>""));//Авторизуемся
- $mdpu_dfn2 = request("http://www.dfn.mdpu.org.ua/course/view.php?id=417", array());//Появляемся на курсе
- $mdpu_dfn2 = request("http://www.dfn.mdpu.org.ua/mod/chat/gui_ajax/index.php?id=19", array());//Появляемся в чате
- echo "<pre>";
- print_r($mdpu_dfn2);
- echo "</pre>";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement