本文整理汇总了PHP中Call::invoke方法的典型用法代码示例。如果您正苦于以下问题:PHP Call::invoke方法的具体用法?PHP Call::invoke怎么用?PHP Call::invoke使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Call
的用法示例。
在下文中一共展示了Call::invoke方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: login
/**
* login
*
* The script checks provided name and password against remote server.
*
* This is done by transmitting the user name and the password to the origin server,
* through a XML-RPC call ([code]drupal.login[/code]).
* On success the origin server will provide the original id for the user profile.
* Else a null id will be returned.
*
* @link http://drupal.org/node/312 Using distributed authentication (drupal.org)
*
* @param string the nickname or the email address of the user
* @param string the submitted password
* @return TRUE on succesful authentication, FALSE othewise
*/
function login($name, $password)
{
global $context;
// we need some parameters
if (!isset($this->attributes['authenticator_parameters']) || !$this->attributes['authenticator_parameters']) {
Logger::error(i18n::s('Please provide parameters to the authenticator.'));
return FALSE;
}
// submit credentials to the authenticating server
include_once $context['path_to_root'] . 'services/call.php';
$result = Call::invoke($this->attributes['authenticator_parameters'], 'drupal.login', array($name, $password), 'XML-RPC');
// invalid result
if (!$result || @count($result) < 2) {
Logger::error(sprintf(i18n::s('Impossible to complete XML-RPC call to %s.'), $this->attributes['authenticator_parameters']));
return FALSE;
}
// successful authentication
if ($result[0] && $result[1] > 0) {
return TRUE;
}
// failed authentication
return FALSE;
}
示例2: ping_as_pingback
/**
* attempt to use the pingback interface
*
* @param string - some text, extracted from the target site, to extract the broker URL, if any
* @param string - the source address
* @param string - the target address from which the text has been extracted
* @return TRUE if the target site has been pinged back, FALSE otherwise
*
* @link http://www.hixie.ch/specs/pingback/pingback Pingback specification
*/
public static function ping_as_pingback($text, $source, $target)
{
global $context;
// extract all <link... /> tags
preg_match_all('/<link(.+?)\\/?>/mi', $text, $links);
// nothing to do
if (!@count($links[1])) {
return FALSE;
}
// look for the broker
$broker = array();
foreach ($links[1] as $link) {
// seek the pingback interface
if (!preg_match('/rel="pingback"/mi', $link)) {
continue;
}
// extract the broker link
if (preg_match('/href="([^"]+)"/mi', $link, $broker)) {
break;
}
}
// pingback interface not supported here
if (!isset($broker[1])) {
return FALSE;
}
// actual pingback, through XML-RPC
include_once $context['path_to_root'] . 'services/call.php';
$result = Call::invoke($broker[1], 'pingback.ping', array($source, $target), 'XML-RPC');
return TRUE;
}
示例3: elseif
// anonymous users are invited to log in or to register
} elseif (!Surfer::is_logged()) {
Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/login.php?url=' . urlencode('servers/ping.php'));
} elseif (!Surfer::is_associate()) {
Safe::header('Status: 401 Unauthorized', TRUE, 401);
Logger::error(i18n::s('You are not allowed to perform this operation.'));
// do the ping
} elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'ping') {
// list servers to be advertised
if ($servers = Servers::list_for_ping(0, 20, 'ping')) {
$context['text'] .= '<p>' . i18n::s('Servers that have been notified') . '</p><ul>';
// ping each server
foreach ($servers as $server_url => $attributes) {
list($server_ping, $server_label) = $attributes;
$milestone = get_micro_time();
$result = @Call::invoke($server_ping, 'weblogUpdates.ping', array(strip_tags($context['site_name']), $context['url_to_home'] . $context['url_to_root']), 'XML-RPC');
if ($result[0]) {
$label = round(get_micro_time() - $milestone, 2) . ' sec.';
} else {
$label = @$result[1];
}
$context['text'] .= '<li>' . $server_label . ' (' . $label . ')</li>';
}
$context['text'] .= '</ul>';
// no server to ping
} else {
$context['text'] .= '<p>' . i18n::s('No server has been created yet.') . '</p>';
}
// back to the index of servers
$menu = array('servers/' => i18n::s('Servers'));
$context['text'] .= Skin::build_list($menu, 'menu_bar');
示例4: array
</p>
<p>sdsd qd qsd qds</p>
<p>al non ? Vivement les plug-ins, qu\'on <FONT size="6" face="Verdana" color="#808000">puisse</FONT> ajouter d\'autres effets.
</p>
<p>qsd qsd qds qjhgkjg k j<br/>
</p>
<a title="" href="http://127.0.0.1/yacs/articles/view.php/4920"><img src="http://127.0.0.1/yacs/files/section/2739/Nnuphars_thumb.jpg" alt="" /></a><!-- technorati tags begin --><p style="font-size:10px;text-align:right;">technorati tags:<a href="http://technorati.com/tag/un" rel="tag">un</a>, <a href="http://technorati.com/tag/tag" rel="tag">tag</a>, <a href="http://technorati.com/tag/xml" rel="tag">xml</a>, <a href="http://technorati.com/tag/rpc" rel="tag">rpc</a></p><!-- technorati tags end -->';
// metaWeblog.newPost -- the Flock way
$context['text'] .= Skin::build_block('metaWeblog.newPost', 'title');
$parameters = array($blogid, $user_name, $user_password, array('title' => $codec->encode('a post from Flock', 'string'), 'description' => $codec->encode($sample_message, 'string'), 'mt_convert_breaks' => '', 'mt_tb_ping_urls' => array('http://www.technorati.com')), TRUE);
$result = Call::invoke($url, 'metaWeblog.newPost', $parameters, 'XML-RPC');
$status = @$result[0];
$data = @$result[1];
// display call result
if (!$status) {
$context['text'] .= 'status: ' . $data;
} elseif (is_array($data) && isset($data['faultString']) && $data['faultString']) {
$context['text'] .= $data['faultString'];
} elseif (is_array($data)) {
$context['text'] .= '?? ';
foreach ($data as $item) {
$context['text'] .= "<p>" . $item . "</p>\n";
}
} else {
$context['text'] .= '"' . $data . '"';
$postid = $data;
示例5: notify
/**
* notify servers about a new page
*
* @param string page URL
* @param string server name
*/
public static function notify($link, $title = NULL)
{
global $context;
if (!$title) {
$title = $context['site_name'];
}
// the list of recipients contacted during overall script execution
if (!isset($context['servers_endpoints'])) {
$context['servers_endpoints'] = array();
}
// list servers to be advertised
if ($servers = Servers::list_for_ping(0, COMPACT_LIST_SIZE, 'ping')) {
// ping each server
include_once $context['path_to_root'] . 'services/call.php';
foreach ($servers as $server_url => $attributes) {
list($server_ping, $server_label) = $attributes;
$milestone = get_micro_time();
$result = Call::invoke($server_ping, 'weblogUpdates.ping', array(strip_tags($title), $context['url_to_home'] . $context['url_to_root'] . $link), 'XML-RPC');
if ($result[0]) {
$server_label .= ' (' . round(get_micro_time() - $milestone, 2) . ' sec.)';
}
$context['servers_endpoints'][] = $server_label;
}
}
}
示例6: encode_field
$input = '<input type="text" name="message" size="30" maxlength="128" value="' . encode_field($message) . '" />';
$fields[] = array($label, $input);
$context['text'] .= Skin::build_form($fields);
$context['text'] .= '</div></form>';
// set the focus at the first field
Page::insert_script('$("#target").focus();');
// process provided parameters
if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST') {
// call json back-end
$url = 'http://' . $_REQUEST['target'] . '/services/json_rpc.php';
// echo
$context['text'] .= Skin::build_block('echo', 'title');
$parameters = array('message' => $message);
include_once 'call.php';
$status = $data = NULL;
if ($result = Call::invoke($url, 'echo', $parameters, 'JSON-RPC')) {
$status = $result[0];
$data = $result[1];
}
// bad call processing
if (!$status) {
$context['text'] .= 'status: ' . $data;
} elseif (!empty($data['error'])) {
if (is_array($data['error'])) {
$context['text'] .= '<p>error:</p><ul class="compact">';
foreach ($data['error'] as $name => $value) {
if ($value) {
$context['text'] .= "<li>" . $name . ': ' . $value . "</li>\n";
}
}
$context['text'] .= "</ul>\n";
示例7: array
$input = '<input type="password" name="user_password" size="30" maxlength="128" value="' . $user_password . '" />';
$fields[] = array($label, $input);
$context['text'] .= Skin::build_form($fields);
$context['text'] .= '</div></form>';
// set the focus at the first field
Page::insert_script('$("#target").focus();');
// process provided parameters
if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST') {
// call blog web service
$url = 'http://' . $_REQUEST['target'] . '/services/xml_rpc.php';
// drupal.login
$context['text'] .= Skin::build_block('drupal.login', 'title');
$parameters = array($user_name, $user_password);
include_once 'call.php';
$status = $data = NULL;
if ($result = Call::invoke($url, 'drupal.login', $parameters, 'XML-RPC')) {
$status = $result[0];
$data = $result[1];
}
// display call result
if (!$status) {
$context['text'] .= 'status: ' . $data;
} elseif (is_array($data) && $data['faultString']) {
$context['text'] .= 'fault: ' . $data['faultString'];
} elseif (is_array($data)) {
$context['text'] .= '?? ';
foreach ($data as $item) {
$context['text'] .= "<p>" . $item . "</p>\n";
}
} else {
$context['text'] .= '"' . $data . '"';
示例8: load_skin
load_skin('services');
// the title of the page
$context['page_title'] = i18n::s('Sample ping client');
// we do have a target to process
if (isset($_REQUEST['target'])) {
// call blog web service
$url = 'http://' . $_REQUEST['target'] . '/services/ping.php';
// pingback.ping
if ($_REQUEST['action'] == 'pingback.ping') {
$context['text'] .= Skin::build_block('pingback.ping', 'title');
$result = Call::invoke($url, 'pingback.ping', array($_REQUEST['source_link'], $_REQUEST['target_link']), 'XML-RPC');
}
// weblogUpdates.ping
if ($_REQUEST['action'] == 'weblogUpdates.ping') {
$context['text'] .= Skin::build_block('weblogUpdates.ping', 'title');
$result = Call::invoke($url, 'weblogUpdates.ping', array(strip_tags($_REQUEST['name']), $_REQUEST['url']), 'XML-RPC');
}
// display call result
$status = @$result[0];
$data = @$result[1];
if (!$status) {
$context['text'] .= $data;
} elseif (is_array($data) && $data['faultString']) {
$context['text'] .= $data['faultString'];
} elseif (is_array($data)) {
foreach ($data as $name => $value) {
$context['text'] .= $name . ': ' . $value . BR . "\n";
}
} else {
$context['text'] .= $data;
}