本文整理汇总了PHP中xmlrpc_is_fault函数的典型用法代码示例。如果您正苦于以下问题:PHP xmlrpc_is_fault函数的具体用法?PHP xmlrpc_is_fault怎么用?PHP xmlrpc_is_fault使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xmlrpc_is_fault函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: query
public function query($method, $parameters = null)
{
$request = xmlrpc_encode_request($method, $parameters);
$headers = array("Content-type: text/xml", "Content-length: " . strlen($request));
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $this->url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_POSTFIELDS, $request);
if ($this->timeout) {
curl_setopt($curl, CURLOPT_TIMEOUT, $this->timeout);
}
$rawResponse = curl_exec($curl);
$curlErrno = curl_errno($curl);
$curlError = curl_error($curl);
curl_close($curl);
if ($curlErrno) {
throw new NetworkException($curlError, $curlErrno);
}
$result = xmlrpc_decode($rawResponse);
if (xmlrpc_is_fault($result)) {
throw new NetworkException($result['faultString'], $result['faultCode']);
}
return $result;
}
示例2: get_response
public static function get_response($server, $request, &$error = null, $fresh = false)
{
$ch = vpl_jailserver_manager::get_curl($server, $request, $fresh);
$raw_response = curl_exec($ch);
if ($raw_response === false) {
$error = 'request failed: ' . s(curl_error($ch));
curl_close($ch);
return false;
} else {
curl_close($ch);
$error = '';
$response = xmlrpc_decode($raw_response, "UTF-8");
if (is_array($response)) {
if (xmlrpc_is_fault($response)) {
$error = 'xmlrpc is fault: ' . s($response["faultString"]);
} else {
return $response;
}
} else {
$error = 'http error ' . s(strip_tags($raw_response));
$fail = true;
}
return false;
}
}
示例3: onStartNoticeSave
function onStartNoticeSave($notice)
{
$args = $this->testArgs($notice);
common_debug("Blogspamnet args = " . print_r($args, TRUE));
$request = xmlrpc_encode_request('testComment', array($args));
$context = stream_context_create(array('http' => array('method' => "POST", 'header' => "Content-Type: text/xml\r\n" . "User-Agent: " . $this->userAgent(), 'content' => $request)));
$file = file_get_contents($this->baseUrl, false, $context);
$response = xmlrpc_decode($file);
if (xmlrpc_is_fault($response)) {
throw new ServerException("{$response['faultString']} ({$response['faultCode']})", 500);
} else {
common_debug("Blogspamnet results = " . $response);
if (preg_match('/^ERROR(:(.*))?$/', $response, $match)) {
throw new ServerException(sprintf(_("Error from %s: %s"), $this->baseUrl, $match[2]), 500);
} else {
if (preg_match('/^SPAM(:(.*))?$/', $response, $match)) {
throw new ClientException(sprintf(_("Spam checker results: %s"), $match[2]), 400);
} else {
if (preg_match('/^OK$/', $response)) {
// don't do anything
} else {
throw new ServerException(sprintf(_("Unexpected response from %s: %s"), $this->baseUrl, $response), 500);
}
}
}
}
return true;
}
示例4: parse
/**
* {@inheritdoc}
*/
public function parse($xmlString, &$isFault)
{
$result = xmlrpc_decode($xmlString, 'UTF-8');
$isFault = false;
$toBeVisited = [&$result];
while (isset($toBeVisited[0]) && ($value =& $toBeVisited[0])) {
$type = gettype($value);
if ($type === 'object') {
$xmlRpcType = $value->{'xmlrpc_type'};
if ($xmlRpcType === 'datetime') {
$value = DateTime::createFromFormat('Ymd\\TH:i:s', $value->scalar, isset($timezone) ? $timezone : ($timezone = new DateTimeZone('UTC')));
} elseif ($xmlRpcType === 'base64') {
if ($value->scalar !== '') {
$value = Base64::serialize($value->scalar);
} else {
$value = null;
}
}
} elseif ($type === 'array') {
foreach ($value as &$element) {
$toBeVisited[] =& $element;
}
}
array_shift($toBeVisited);
}
if (is_array($result)) {
reset($result);
$isFault = xmlrpc_is_fault($result);
}
return $result;
}
示例5: onStartNoticeSave
function onStartNoticeSave($notice)
{
$args = $this->testArgs($notice);
common_debug("Blogspamnet args = " . print_r($args, TRUE));
$requestBody = xmlrpc_encode_request('testComment', array($args));
$request = new HTTPClient($this->baseUrl, HTTPClient::METHOD_POST);
$request->setHeader('Content-Type', 'text/xml');
$request->setBody($requestBody);
$httpResponse = $request->send();
$response = xmlrpc_decode($httpResponse->getBody());
if (xmlrpc_is_fault($response)) {
throw new ServerException("{$response['faultString']} ({$response['faultCode']})", 500);
} else {
common_debug("Blogspamnet results = " . $response);
if (preg_match('/^ERROR(:(.*))?$/', $response, $match)) {
throw new ServerException(sprintf(_("Error from %s: %s"), $this->baseUrl, $match[2]), 500);
} else {
if (preg_match('/^SPAM(:(.*))?$/', $response, $match)) {
throw new ClientException(sprintf(_("Spam checker results: %s"), $match[2]), 400);
} else {
if (preg_match('/^OK$/', $response)) {
// don't do anything
} else {
throw new ServerException(sprintf(_("Unexpected response from %s: %s"), $this->baseUrl, $response), 500);
}
}
}
}
return true;
}
示例6: isFault
/**
* This method checks whether the given argument is an XML-RPC fault.
*
* @param mixed $fault
*
* @return bool
*/
public static function isFault($fault)
{
if (isset($fault) && is_array($fault)) {
return xmlrpc_is_fault($fault);
} else {
return false;
}
}
示例7: get_xmlrpc_error
function get_xmlrpc_error($resp)
{
if (is_array($resp) && xmlrpc_is_fault($resp)) {
$message = 'Moodle Integrator - ' . $resp['faultCode'] . ' - ' . $resp['faultString'];
return ErrorMessage(array($message), 'error');
}
return null;
}
示例8: ping_broadcast_notice
function ping_broadcast_notice($notice)
{
if ($notice->is_local != Notice::LOCAL_PUBLIC && $notice->is_local != Notice::LOCAL_NONPUBLIC) {
return true;
}
# Array of servers, URL => type
$notify = common_config('ping', 'notify');
$profile = $notice->getProfile();
$tags = ping_notice_tags($notice);
foreach ($notify as $notify_url => $type) {
switch ($type) {
case 'xmlrpc':
case 'extended':
$req = xmlrpc_encode_request('weblogUpdates.ping', array($profile->nickname, common_local_url('showstream', array('nickname' => $profile->nickname)), common_local_url('shownotice', array('notice' => $notice->id)), common_local_url('userrss', array('nickname' => $profile->nickname)), $tags));
$request = HTTPClient::start();
$request->setConfig('connect_timeout', common_config('ping', 'timeout'));
$request->setConfig('timeout', common_config('ping', 'timeout'));
try {
$httpResponse = $request->post($notify_url, array('Content-Type: text/xml'), $req);
} catch (Exception $e) {
common_log(LOG_ERR, "Exception pinging {$notify_url}: " . $e->getMessage());
continue;
}
if (!$httpResponse || mb_strlen($httpResponse->getBody()) == 0) {
common_log(LOG_WARNING, "XML-RPC empty results for ping ({$notify_url}, {$notice->id}) ");
continue;
}
$response = xmlrpc_decode($httpResponse->getBody());
if (is_array($response) && xmlrpc_is_fault($response)) {
common_log(LOG_WARNING, "XML-RPC error for ping ({$notify_url}, {$notice->id}) " . "{$response['faultString']} ({$response['faultCode']})");
} else {
common_log(LOG_INFO, "Ping success for {$notify_url} {$notice->id}");
}
break;
case 'get':
case 'post':
$args = array('name' => $profile->nickname, 'url' => common_local_url('showstream', array('nickname' => $profile->nickname)), 'changesURL' => common_local_url('userrss', array('nickname' => $profile->nickname)));
$fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
if ($type === 'get') {
$result = $fetcher->get($notify_url . '?' . http_build_query($args), array('User-Agent: StatusNet/' . STATUSNET_VERSION));
} else {
$result = $fetcher->post($notify_url, http_build_query($args), array('User-Agent: StatusNet/' . STATUSNET_VERSION));
}
if ($result->status != '200') {
common_log(LOG_WARNING, "Ping error for '{$notify_url}' ({$notice->id}): " . "{$result->body}");
} else {
common_log(LOG_INFO, "Ping success for '{$notify_url}' ({$notice->id}): " . "'{$result->body}'");
}
break;
default:
common_log(LOG_WARNING, 'Unknown notify type for ' . $notify_url . ': ' . $type);
}
}
return true;
}
示例9: call
/**
* Calls the method on the server with the given parameters
*
* @param string $method The method name
* @param array $parameters The argument parameters for the method
*
* @return string
*/
protected function call($method, array $parameters = array())
{
$request = xmlrpc_encode_request($method, $parameters);
$context = stream_context_create(array('http' => array('method' => "POST", 'header' => "Content-Type: text/xml", 'content' => $request)));
$contents = $this->fileRetriever->retrieveContents($this->getDSN(), $context);
$response = xmlrpc_decode($contents);
if ($response && is_array($response) && xmlrpc_is_fault($response)) {
trigger_error("xmlrpc: {$response['faultString']} ({$response['faultCode']})");
}
return $response;
}
示例10: normalValidate
function normalValidate($command, $la, $code)
{
$request = xmlrpc_encode_request("validate", array($command, $la, AV_LOGIN, AV_PASSWD, $code));
$context = stream_context_create(array('http' => array('method' => "POST", 'header' => "Content-Type: text/xml", 'content' => $request)));
$file = file_get_contents(AV_RPC_URL, false, $context);
$response = xmlrpc_decode($file);
if (xmlrpc_is_fault($response)) {
return false;
}
return $response['status'] == "OK";
}
示例11: execute
public function execute($server)
{
$file = file_get_contents($server, false, $this->context);
if ($file == false) {
throw new Exception("Server didn't send an answer!");
}
$response = xmlrpc_decode($file);
if (is_array($response) && xmlrpc_is_fault($response)) {
throw new XMLRPCException($response['faultString'], $response['faultCode']);
}
return $response;
}
示例12: commit_rpc
protected function commit_rpc()
{
$request = xmlrpc_encode_request($this->method, $this->parms);
$context = stream_context_create(array('http' => array('method' => "POST", 'header' => "Content-Type: text/xml; charset=utf-8\r\n" . "User-Agent: XMLRPC::Client JorgeRPCclient", 'content' => $request)));
$file = file_get_contents("http://{$this->rpc_server}" . ":" . "{$this->rpc_port}", false, $context);
$response = xmlrpc_decode($file, "utf8");
if (xmlrpc_is_fault($response)) {
throw new Exception("XML-RPC Call Failed. Unrecoverable condition", 0);
} else {
return $response;
}
}
示例13: __call
public function __call($method, array $parameters = array())
{
$request = xmlrpc_encode_request(strlen($this->_namespace) > 0 ? "{$this->_namespace}.{$method}" : $method, $parameters);
$context = stream_context_create(array('http' => array('method' => "POST", 'header' => "Content-Type: text/xml", 'content' => $request)));
$file = file_get_contents($this->_url, false, $context);
$response = xmlrpc_decode($file);
if (is_null($response)) {
throw new XmlRpcClientException(array('faultString' => 'Invalid response from ' . $this->_url, 'faultCode' => 999));
}
if (@xmlrpc_is_fault($response)) {
throw new XmlRpcClientException($response);
}
return $response;
}
示例14: __call
public function __call($name, $arguments)
{
error_log("[FreesideSelfService] {$name} called, sending to " . $this->URL);
$request = xmlrpc_encode_request("FS.SelfService.XMLRPC.{$name}", $arguments);
$context = stream_context_create(array('http' => array('method' => "POST", 'header' => "Content-Type: text/xml", 'content' => $request)));
$file = file_get_contents($this->URL, false, $context);
$response = xmlrpc_decode($file);
if (xmlrpc_is_fault($response)) {
trigger_error("[FreesideSelfService] XML-RPC communication error: {$response['faultString']} ({$response['faultCode']})");
} else {
//error_log("[FreesideSelfService] $response");
return $response;
}
}
示例15: make_request
function make_request($xml, &$output)
{
/* НАЧАЛО ЗАПРОСА */
$options = ['http' => ['method' => "POST", 'header' => "User-Agent: PHPRPC/1.0\r\n" . "Content-Type: text/xml\r\n" . "Content-length: " . strlen($xml) . "\r\n\n", 'content' => "{$xml}"]];
$context = stream_context_create($options);
$retval = file_get_contents('http://phpoopsite.local/xml-rpc/xml-rpc-server.php', false, $context);
/* КОНЕЦ ЗАПРОСА */
$data = xmlrpc_decode($retval);
if (is_array($data) && xmlrpc_is_fault($data)) {
$output = $data;
} else {
$output = unserialize(base64_decode($data));
}
}