本文整理汇总了PHP中HttpClient::getStatus方法的典型用法代码示例。如果您正苦于以下问题:PHP HttpClient::getStatus方法的具体用法?PHP HttpClient::getStatus怎么用?PHP HttpClient::getStatus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpClient
的用法示例。
在下文中一共展示了HttpClient::getStatus方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parse
function parse($raw)
{
// TODO XmlReader should not handle HTTP protocol details
if (is_url($raw)) {
$url = $raw;
$h = new HttpClient($url);
// $h->setCacheTime('30m');
$raw = $h->getBody();
// d( $h->getResponseHeaders() );
if ($h->getStatus() == 404) {
// not found
return false;
}
if ($h->getStatus() == 302) {
$redir = $h->getResponseHeader('location');
// echo "REDIRECT: ".$redir."\n";
$h = new HttpClient($redir);
//XXX: reuse previous client?
$h->setCacheTime('30m');
$url = $redir;
$raw = $h->getBody();
}
// prepend XML header if nonexistent
if (strpos($raw, '<?xml ') === false) {
$raw = '<?xml version="1.0"?>' . $raw;
}
}
if (!$this->xml($raw)) {
if (isset($url)) {
throw new \Exception("Failed to parse XML from " . $url);
}
throw new \Exception("Failed to parse XML");
}
}
示例2: sendVerifyRemoteRequest
/**
* 获取校验结果
* @param $ssid
* @param $result
* @param int $diff
* @return type
*/
public static function sendVerifyRemoteRequest($ssid, $result, $diff = 0)
{
$client = new HttpClient(App::getConfig('YUC_SERVICE_NAME'), App::getConfig('YUC_SERVICE_PORT'));
$client->setTimeout(App::getConfig('YUC_CLIENT_TIMEOUT'));
//设置超时
$client->post(App::getConfig('YUC_VERIFY_PATH'), array('site_key' => App::getConfig('YUC_SITE_KEY'), 'ssid' => $ssid, 'result' => $result, 'diffsec_client' => $diff));
$post_req = json_decode($client->getContent(), TRUE);
Log::Write('远程验证完成,输入结果为:' . $result . ',返回状态 :' . $client->getStatus() . ';' . 'POST 验证码正确性请求返回的数据:' . $client->getContent(), Log::DEBUG);
if ($client->getStatus() == 200 && is_array($post_req)) {
//200状态 正常返回数据 且返回数据格式正常
self::$_yuc_code = $post_req['code'];
self::$_yuc_details = $post_req['details'];
self::$_yuc_result = $post_req['result'];
} else {
self::$_yuc_code = 'E_SEVERVALID_001';
self::$_yuc_details = '服务器请求失败!';
self::$_yuc_result = 0;
}
return array('code' => self::$_yuc_code, 'result' => self::$_yuc_result, 'details' => self::$_yuc_details);
}
示例3: processQueue
//.........这里部分代码省略.........
//fixme: source & destination should not be able to be the same!
$dst_file = 'tmpfile.mp3';
$c = '/usr/local/bin/ffmpeg -i "' . $h->files->findUploadPath($job['referId']) . '" ' . $dst_file;
break;
default:
die('unknown destination audio format: ' . $job['orderParams']);
}
echo 'Executing: ' . $c . "\n";
$exec_time = exectime($c);
echo 'Execution time: ' . shortTimePeriod($exec_time) . "\n";
if (!file_exists($dst_file)) {
echo '<b>FAILED - dst file ' . $dst_file . " dont exist!\n";
break;
}
//FIXME: behöver inget rename-steg. kan skriva till rätt output fil i första steget
rename($dst_file, $h->files->upload_dir . $newId);
$h->files->updateFile($newId);
markQueueCompleted($job['entryId'], $exec_time);
break;
case TASK_VIDEO_RECODE:
echo "VIDEO RECODE:\n";
$exec_start = microtime(true);
if (convertVideo($job['referId'], $job['orderParams']) === false) {
markQueue($job['entryId'], ORDER_FAILED);
} else {
markQueueCompleted($job['entryId'], microtime(true) - $exec_start);
}
break;
case TASK_FETCH:
echo "FETCH CONTENT\n";
$fileName = basename($job['orderParams']);
//extract filename part of url, used as "filename" in database
$http = new HttpClient($job['orderParams']);
$http->getHead();
if ($http->getStatus() != 200) {
// retry in 20 seconds if file is not yet ready
retryQueueEntry($job['entryId'], 20);
break;
}
$newFileId = FileList::createEntry(FILETYPE_PROCESS, 0, 0, $fileName);
$c = 'wget ' . escapeshellarg($job['orderParams']) . ' -O ' . FileInfo::getUploadPath($newFileId);
echo "\$ " . $c . "\n";
$retval = 0;
$exec_time = exectime($c, $retval);
if (!$retval) {
//TODO: process html document for media links if it is a html document
TaskQueue::markTaskCompleted($job['entryId'], $exec_time, $newFileId);
FileInfo::updateData($newFileId);
} else {
//wget failed somehow, delay work for 1 minute
retryQueueEntry($job['entryId'], 60);
$files->deleteFile($newFileId, 0, true);
//remove failed local file entry
}
break;
case TASK_CONVERT_TO_DEFAULT:
echo "CONVERT TO DEFAULT\n";
//referId is entryId of previous proccess queue order
$params = unserialize($job['orderParams']);
$prev_job = TaskQueue::getEntry($job['referId']);
if ($prev_job['orderStatus'] != ORDER_COMPLETED) {
retryQueueEntry($job['entryId'], 60);
break;
}
$file = $files->getFileInfo($prev_job['referId']);
$exec_start = microtime(true);
$newId = false;
switch ($file['mediaType']) {
case MEDIATYPE_VIDEO:
$newId = convertVideo($prev_job['referId'], $h->files->default_video, !empty($params['callback']) ? false : true, !empty($params['watermark']) ? $params['watermark'] : '');
break;
case MEDIATYPE_AUDIO:
$newId = convertAudio($prev_job['referId'], $h->files->default_audio);
break;
default:
echo "UNKNOWN MEDIA TYPE " . $file['mediaType'] . ", MIME TYPE " . $file['fileMime'] . ", CANNOT CONVERT MEDIA!!!\n";
break;
}
if (!$newId) {
markQueue($job['entryId'], ORDER_FAILED);
return false;
}
markQueueCompleted($job['entryId'], microtime(true) - $exec_start);
if (empty($params['callback'])) {
break;
}
//'uri' isnt known before the new file is created so it is added at this point
$uri = $config['core']['full_url'] . 'api/file.php?id=' . $newId;
$params['callback'] .= (strpos($params['callback'], '?') !== false ? '&' : '?') . 'uri=' . urlencode($uri);
$data = file_get_contents($params['callback']);
echo "Performing callback: " . $params['callback'] . "\n\n";
echo "Callback script returned:\n" . $data;
storeCallbackData($job['entryId'], $data, $params);
break;
default:
echo "Unknown ordertype: " . $job['orderType'] . "\n";
d($job);
die;
}
}
示例4: HttpClient
function _upload($args, $path, $timeout)
{
global $request;
$reaction = 'upload ';
if ($args['noupload']) {
return $reaction . _("skipped");
}
//$userid = $request->_user->_userid;
$url = $args['url'];
$url = str_replace("/RPC2.php", "/index.php", $url);
$server = parse_url($url);
$http = new HttpClient($server['host'], $server['port']);
$http->timeout = $timeout + 5;
$success = $http->postfile($server['url'], $path);
if ($success) {
if ($http->getStatus() == 200) {
$reaction .= _("OK");
} else {
$reaction .= _("FAILED") . ' ' . $http->getStatus();
}
} else {
$reaction .= _("FAILED") . ' ' . $http->getStatus() . " " . $http->errormsg;
}
return $reaction;
}
示例5: ajaxcheckandsaveAction
public function ajaxcheckandsaveAction()
{
$this->_helper->layout->disableLayout();
$code = urldecode($this->_request->getParam('code'));
$config = Zend_Registry::get('config');
$writer_host = $config->writer->host;
$uri = "/sns/find_sns.json";
//TODO: use config.ini
$client = new HttpClient("localhost", "4000");
$access_token = NULL;
$access_token_secret = NULL;
$refresh_access_token = NULL;
$expires_at = NULL;
$expires_in = NULL;
$username = NULL;
$user = NULL;
$nick = NULL;
$profile_img_path = NULL;
$big_profile_img_path = NULL;
$small_profile_img_path = NULL;
$client->get($uri, array('code' => $code));
if ($client->getStatus() == "200") {
$rs = json_decode($client->getContent());
if (isset($rs->access_token_secret)) {
$access_token_secret = $rs->access_token_secret;
}
if (isset($rs->refresh_access_token)) {
$refresh_access_token = $rs->refresh_access_token;
}
if (isset($rs->expires_at)) {
$expires_at = $rs->expires_at;
}
if (isset($rs->expires_in)) {
$expires_in = $rs->expires_in;
}
if (isset($rs->username)) {
$username = $rs->username;
}
if (isset($rs->user)) {
$user = $rs->user;
}
if (isset($rs->nick)) {
$nick = $rs->nick;
}
if (isset($rs->profile_img_path)) {
$profile_img_path = $rs->profile_img_path;
}
if (isset($rs->big_profile_img_path)) {
$big_profile_img_path = $rs->big_profile_img_path;
}
if (isset($rs->small_profile_img_path)) {
$small_profile_img_path = $rs->small_profile_img_path;
}
$sns = new Sns();
$row = $sns->fetchRow($sns->select()->where('access_token = ?', $rs->access_token));
if (isset($row)) {
$data = array('access_token' => $rs->access_token);
$where = $sns->getAdapter()->quoteInto('id = ?', $row->id);
$sns->update($data, $where);
} else {
try {
$data = array('code' => $code, 'access_token' => $rs->access_token, 'access_token_secret' => $access_token_secret, 'refresh_access_token' => $refresh_access_token, 'expires_at' => $expires_at, 'expires_in' => $expires_in, 'consumer' => (int) $this->_currentUser->id, 'source' => $rs->source, 'timestamp' => date("Y-m-d H:i:s"), 'username' => $username, 'user' => $user, 'nick' => $nick, 'profile_img_path' => $profile_img_path, 'big_profile_img_path' => $big_profile_img_path, 'small_profile_img_path' => $small_profile_img_path);
$sns->insert($data);
$this->_helper->json(1);
} catch (Exception $e) {
print_r($e);
}
}
$response = array("status" => 1);
} else {
$response = array("status" => 0);
}
$this->getHelper('json')->sendJson($response);
}
示例6: getAlbumDetails
/**
* @param $album_id spotify uri
*/
function getAlbumDetails($album_id)
{
if (!is_spotify_uri($album_id)) {
return false;
}
$url = 'http://ws.spotify.com/lookup/1/?uri=' . $album_id . '&extras=trackdetail';
$http = new HttpClient($url);
// $http->setCacheTime(60*60*24); //24 hours
$data = $http->getBody();
if ($http->getStatus() != 200) {
d('SpotifyMetadata->getAlbumDetails server error: ' . $http->getStatus());
d($http->getResponseHeaders());
return false;
}
return $this->parseAlbumDetails($data);
}
示例7: startAction
//.........这里部分代码省略.........
$NICELog->WriteLog('Server Connect Error!!' . $httpclient->getErrorMsg());
$resultMsg = $httpclient->getErrorMsg() . "서버연결을 할 수가 없습니다.";
if ($this->m_ssl == "true") {
$resultMsg .= "<br>귀하의 서버는 SSL통신을 지원하지 않습니다. 결제처리파일에서 m_ssl=false로 셋팅하고 시도하세오.";
$this->MakeErrorMsg(ERR_SSLCONN, $resultMsg);
} else {
$this->MakeErrorMsg(ERR_CONN, $resultMsg);
}
$NICELog->CloseNiceLog("");
return;
}
//request
if (!$httpclient->HttpRequest($this->m_uri, $this->m_queryString, $NICELog)) {
// 요청 오류시 처리
$NICELog->WriteLog('POST Error!!' . $httpclient->getErrorMsg());
$this->MakeErrorMsg(ERR_NO_RESPONSE, "서버 응답 오류");
//NET CANCEL Start---------------------------------
if ($httpclient->getErrorCode() == READ_TIMEOUT_ERR) {
$NICELog->WriteLog("Net Cancel Start");
$this->m_uri = "/lite/cancelProcess.jsp";
unset($this->m_queryString);
$this->m_queryString["MID"] = substr($this->m_TID, 0, 10);
$this->m_queryString["TID"] = $this->m_TID;
$this->m_queryString["CancelAmt"] = $this->m_NetCancelAmt;
$this->m_queryString["CancelMsg"] = "NICE_NET_CANCEL";
$this->m_queryString["CancelPwd"] = $this->m_NetCancelPW;
$this->m_queryString["NetCancelCode"] = "1";
$NICELog->WriteLog($this->m_queryString["TID"]);
if (!$httpclient->HttpConnect($NICELog)) {
$NICELog->WriteLog('Server Connect Error!!' . $httpclient->getErrorMsg());
$resultMsg = $httpclient->getErrorMsg() . "서버연결을 할 수가 없습니다.";
$this->MakeErrorMsg(ERR_CONN, $resultMsg);
$NICELog->CloseNiceLog($this->m_resultMsg);
return;
}
if (!$httpclient->HttpRequest($this->m_uri, $this->m_queryString, $NICELog) && $httpclient->getErrorCode() == READ_TIMEOUT_ERR) {
$NICELog->WriteLog("Net Cancel FAIL");
if ($this->m_ActionType == "PYO") {
$this->MakeErrorMsg(ERR_NO_RESPONSE, "승인여부 확인요망");
} else {
if ($this->m_ActionType == "CLO") {
$this->MakeErrorMsg(ERR_NO_RESPONSE, "취소여부 확인요망");
}
}
} else {
$NICELog->WriteLog("Net Cancel SUCESS");
}
}
//NET CANCEL End---------------------------------
$this->ParseMsg($httpclient->getBody(), $NICELog);
$NICELog->CloseNiceLog($this->m_resultMsg);
return;
}
if ($httpclient->getStatus() == "200") {
$this->ParseMsg($httpclient->getBody(), $NICELog);
$NICELog->WriteLog("TID -> " . "[" . $this->m_ResultData['TID'] . "]");
$NICELog->WriteLog($this->m_ResultData['ResultCode'] . "[" . $this->m_ResultData['ResultMsg'] . "]");
$NICELog->CloseNiceLog("");
} else {
$NICELog->WriteLog('SERVER CONNECT FAIL:' . $httpclient->getStatus() . $httpclient->getErrorMsg() . $httpclient->getHeaders());
$resultMsg = $httpclient->getStatus() . "서버에러가 발생했습니다.";
$this->MakeErrorMsg(ERR_NO_RESPONSE, $resultMsg);
//NET CANCEL Start---------------------------------
if ($httpclient->getStatus() != 200) {
$NICELog->WriteLog("Net Cancel Start");
//Set Field
$this->m_uri = "/lite/cancelProcess.jsp";
unset($this->m_queryString);
$this->m_queryString["MID"] = substr($this->m_TID, 0, 10);
$this->m_queryString["TID"] = $this->m_TID;
$this->m_queryString["CancelAmt"] = $this->m_NetCancelAmt;
$this->m_queryString["CancelMsg"] = "NICE_NET_CANCEL";
$this->m_queryString["CancelPwd"] = $this->m_NetCancelPW;
$this->m_queryString["NetCancelCode"] = "1";
if (!$httpclient->HttpConnect($NICELog)) {
$NICELog->WriteLog('Server Connect Error!!' . $httpclient->getErrorMsg());
$resultMsg = $httpclient->getErrorMsg() . "서버연결을 할 수가 없습니다.";
$this->MakeErrorMsg(ERR_CONN, $resultMsg);
$NICELog->CloseNiceLog($this->m_resultMsg);
return;
}
if (!$httpclient->HttpRequest($this->m_uri, $this->m_queryString, $NICELog)) {
$NICELog->WriteLog("Net Cancel FAIL");
if ($this->m_ActionType == "PYO") {
$this->MakeErrorMsg(ERR_NO_RESPONSE, "승인여부 확인요망");
} else {
if ($this->m_ActionType == "CLO") {
$this->MakeErrorMsg(ERR_NO_RESPONSE, "취소여부 확인요망");
}
}
} else {
$NICELog->WriteLog("Net Cancel SUCESS");
}
}
//NET CANCEL End---------------------------------
$this->ParseMsg($httpclient->getBody(), $NICELog);
$NICELog->CloseNiceLog("");
return;
}
}
示例8: getInfo
/**
* Returns details on a movie
*
* @param $movie_id TMDB id
*/
public function getInfo($movie_id)
{
if (!self::probeId($movie_id)) {
throw new \Exception('not a tmdb id');
}
if ($this->cache_results) {
$temp = TempStore::getInstance();
$key = 'TheMovieDbClient/info//' . $movie_id;
$data = $temp->get($key);
if ($data) {
return unserialize($data);
}
}
$url = 'http://api.themoviedb.org/3/movie/' . $movie_id . '?language=' . $this->language . '&api_key=' . $this->api_key;
$http = new HttpClient($url);
$data = $http->getBody();
if ($http->getStatus() != 200) {
d('TheMovieDbClient getInfo server error: ' . $http->getStatus());
d($http->getResponseHeaders());
return false;
}
$res = Json::decode($data);
if ($this->cache_results) {
$temp->set($key, serialize($res), '24h');
}
return $res;
}