mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-24 05:39:58 +09:00
XE의 FileHandler::getRemoteFile을 PEAR::HTTPReuqest를 이용하도록 수정.
FileHandler::getRemoteResource를 FileHandler::getRemoteFile 에서 다시 사용하도록 하고 config.inc.php에서 __PROXY_SERVER__ 라는 상수를 통해 특정 서버를 거쳐서 외부 요청을 하는 기능 추가 git-svn-id: http://xe-core.googlecode.com/svn/sandbox@6037 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
1ce3a67992
commit
a1f49ed545
4 changed files with 69 additions and 75 deletions
|
|
@ -3,11 +3,9 @@
|
|||
var $user_id = null;
|
||||
var $user_key = null;
|
||||
|
||||
var $api_url = 'http://me2day.net:80';
|
||||
var $application_key = '537a368d9049d9e86b2b169d75a2a4c3';
|
||||
|
||||
var $api_host = 'me2day.net';
|
||||
var $api_port = 80;
|
||||
|
||||
function me2api($user_id, $user_key) {
|
||||
$this->user_id = $user_id;
|
||||
$this->user_key = $user_key;
|
||||
|
|
@ -29,9 +27,7 @@
|
|||
}
|
||||
|
||||
function _getContent($method, $user_id = null, $params = null) {
|
||||
$host = $this->api_host;
|
||||
$path = $this->_getPath($method, $user_id);
|
||||
$port = $this->api_port;
|
||||
$url = $this->api_url.$this->_getPath($method, $user_id);
|
||||
$auth = base64_encode($this->user_id.':'.$this->_getAuthKey());
|
||||
|
||||
$arr_content = array();
|
||||
|
|
@ -39,35 +35,16 @@
|
|||
foreach($params as $key => $val) {
|
||||
$arr_content[] = sprintf('%s=%s', $key, urlencode($val));
|
||||
}
|
||||
$content = implode('&',$arr_content);
|
||||
$body = implode('&',$arr_content);
|
||||
}
|
||||
$header = sprintf(
|
||||
"POST %s HTTP/1.0\r\n".
|
||||
"Host: %s\r\n".
|
||||
"me2_application_key: %s\r\n".
|
||||
"Content-Type: application/x-www-form-urlencoded\r\n".
|
||||
"Authorization: Basic %s\r\n".
|
||||
"Content-Length: %d\r\n\r\n",
|
||||
$path,
|
||||
$host,
|
||||
$this->application_key,
|
||||
$auth,
|
||||
strlen($content)
|
||||
);
|
||||
if($content) $header.=$content."\r\n\r\n";
|
||||
|
||||
$fp = fsockopen($host, $port);
|
||||
if(!$fp) return null;
|
||||
fwrite($fp, $header);
|
||||
|
||||
$started = false;
|
||||
while(!feof($fp)) {
|
||||
$str = fgets($fp, 1024);
|
||||
if(!trim($str)) $started = true;
|
||||
if($started) $buff .= $str;
|
||||
}
|
||||
fclose($fp);
|
||||
return trim($buff);
|
||||
$buff = FileHandler::getRemoteResource($url, $body, 3, 'POST', 'application/x-www-form-urlencoded',
|
||||
array(
|
||||
'me2_application_key'=>$this->application_key,
|
||||
'Authorization'=>'Basic '.$auth,
|
||||
)
|
||||
);
|
||||
return $buff;
|
||||
}
|
||||
|
||||
function chkNoop() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue