티스토리 뷰
http://tetris.tistory.com/328
- function get_web_data($url)
- {
- $info = parse_url($url);
- $send = "POST " . $info["path"] . " HTTP/1.1\r\n"
- . "Host: " . $info["host"] . "\r\n"
- . "Content-type: application/x-www-form-urlencoded\r\n"
- . "Connection: close\r\n\r\n" ;
- $fp = fsockopen($info["host"], 80);
- fputs($fp, $send);
- $start = false;
- $raw_data = null;
- while (!feof ($fp))
- {
- $tmp = fgets($fp, 1024);
- if ($start == true) $raw_data .= $tmp;
- if ($tmp == "\r\n") $start = true;
- }
- fclose($fp);
- return $raw_data;
- }
- function get_web_header($url)
- {
- $info = parse_url($url);
- $send = "GET " . $info["path"] . " HTTP/1.1\r\n";
- $send .= "Host: ".$info["host"]."\r\n";
- $send .= "Connection: Close\r\n\r\n";
- $fp = fsockopen($info["host"], 80);
- fputs($fp, $send);
- $start = false;
- $header = array();
- $count = 0;
- while (!feof ($fp))
- {
- $tmp = fgets($fp, 128);
- if ($start == true) break;
- else
- {
- if ($tmp != "\r\n")
- {
- $header[$count] = $tmp;
- $count++;
- }
- }
- if ($tmp == "\r\n") $start = true;
- }
- fclose($fp);
- return $header;
- }
--------------------
- function is_exist_remote_file($url)
- {
- if (emptyempty($url) == true) return false;
- $value = $this->get_web_header($url);
- $pos = strpos($value[0], "200 OK");
- if ($pos > 0) return true;
- return false;
- }
'dev > php' 카테고리의 다른 글
구글 그래프 그리기 라이브러리.. (0) | 2011.02.14 |
---|---|
구글 Analytics PHP 라이브러리 :: The Google Analytics API and PHP (0) | 2011.02.14 |
PHP용 트위터 OAuth연동라이브러리 twitteroauth 사용법 (0) | 2011.02.07 |
미투데이(Me2day) 오픈api를 이용한 인증 및 글쓰기 (0) | 2011.02.07 |
[Code Igniter] index.php 없애기 (0) | 2011.01.09 |
공지사항