本文整理汇总了PHP中API类的典型用法代码示例。如果您正苦于以下问题:PHP API类的具体用法?PHP API怎么用?PHP API使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了API类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: __construct
function __construct($city_code = 'Palaiseau', $lang = 'fr')
{
$prefix_images = 'https://www.google.com/';
$url = 'http://www.google.com/ig/api?weather=' . urlencode($city_code) . '&hl=' . $lang;
$api = new API($url);
$xml = simplexml_load_string($api->response());
if ($xml === false) {
throw new Exception("Unable to read Google Weather data");
}
if (isset($xml->weather->problem_cause)) {
throw new Exception($xml->weather->problem_cause);
}
if (isset($xml->weather->current_conditions)) {
$current_conditions = $xml->weather->current_conditions;
$this->today = new WeatherConditions();
$this->today->label = isset($current_conditions->condition) ? $this->getAttrData($current_conditions->condition) : null;
$this->today->temperature = isset($current_conditions->temp_c) ? $this->getAttrData($current_conditions->temp_c) : null;
$icon = isset($current_conditions->icon) ? $this->getAttrData($current_conditions->icon) : null;
$this->today->icon = $icon ? $prefix_images . $icon : null;
} else {
$this->today = null;
}
$this->forecasts = array();
foreach ($xml->weather->forecast_conditions as $aforecast) {
$forecast = new WeatherConditions();
$forecast->label = isset($aforecast->condition) ? $this->getAttrData($aforecast->condition) : null;
$forecast->low = isset($aforecast->low) ? $this->getAttrData($aforecast->low) : null;
$forecast->high = isset($aforecast->high) ? $this->getAttrData($aforecast->high) : null;
$icon = isset($current_conditions->icon) ? $this->getAttrData($current_conditions->icon) : null;
$forecast->icon = $icon ? $prefix_images . $icon : null;
$forecast->day = isset($aforecast->day_of_week) ? $this->getAttrData($aforecast->day_of_week) : null;
$this->forecasts[] = $forecast;
}
}
开发者ID:netixx,项目名称:frankiz,代码行数:34,代码来源:googleweather.php
示例2: response
private static function response()
{
try {
$api = new API(self::$url, false);
$xml = simplexml_load_string(utf8_decode($api->response()));
if ($xml) {
$response = $xml->concerts->children();
$response2 = $xml->concerts_later->children();
} else {
$response = array();
}
$return = array();
foreach ($response as $r) {
//withpic true signifie avec les photos, sinon false. cela depend de la date de concerts <= 30 ou pas
$return[] = array('withpic' => "true", 'group' => (string) $r->nom_groupe, 'link_group' => (string) $r->lien_nom_groupe, 'place' => (string) $r->nom_salle, 'link_place' => (string) $r->lien_nom_salle, 'date' => (string) $r->date, 'price' => (string) $r->prix . ' euro', 'pict' => (string) $r->img_groupe, 'link_pict' => (string) $r->lien_img_groupe);
}
foreach ($response2 as $r) {
//withpic true signifie avec les photos, sinon false. cela depend de la date de concerts <= 30 ou pas
$return[] = array('withpic' => "false", 'group' => (string) $r->nom_groupe, 'link_group' => (string) $r->lien_nom_groupe, 'place' => (string) $r->nom_salle, 'link_place' => (string) $r->lien_nom_salle, 'date' => (string) $r->date, 'price' => (string) $r->prix . ' euro', 'pict' => (string) $r->img_groupe, 'link_pict' => (string) $r->lien_img_groupe);
}
return $return;
} catch (Exception $e) {
return array();
}
}
开发者ID:netixx,项目名称:frankiz,代码行数:25,代码来源:concertloader.php
示例3: action_admin_bar_menu
public function action_admin_bar_menu($wp_admin_bar)
{
$api = new API();
$name = $api->get_site_name();
$site_id = $api->get_site_id();
$env = $this->get_environment();
$title = '<img src="' . esc_url(plugins_url('assets/img/pantheon-fist-color.svg', PANTHEON_HUD_ROOT_FILE)) . '" />';
$bits = array();
if ($name) {
$bits[] = $name;
}
$bits[] = $env;
$title .= ' ' . esc_html(strtolower(implode(':', $bits)));
$wp_admin_bar->add_node(array('id' => 'pantheon-hud', 'href' => false, 'title' => $title));
$env_admins = '';
# TODO: List envs from API to include Multidev.
foreach (array('dev', 'test', 'live') as $e) {
$url = $api->get_primary_environment_url($e);
if ($url) {
$env_admins .= '<a target="_blank" href="' . esc_url(rtrim($url) . '/wp-admin/') . '">' . esc_html($e) . '</a> | ';
}
}
if (!empty($env_admins)) {
$wp_admin_bar->add_node(array('id' => 'pantheon-hud-wp-admin-links', 'parent' => 'pantheon-hud', 'href' => false, 'title' => '<em>wp-admin links</em><br />' . rtrim($env_admins, ' |')));
}
$environment_details = $api->get_environment_details();
if ($environment_details) {
$details_html = array();
if (isset($environment_details['web']['appserver_count'])) {
$pluralize = $environment_details['web']['appserver_count'] > 1 ? 's' : '';
$web_detail = $environment_details['web']['appserver_count'] . ' app container' . $pluralize;
if (isset($environment_details['web']['php_version'])) {
$web_detail .= ' running ' . $environment_details['web']['php_version'];
}
$details_html[] = $web_detail;
}
if (isset($environment_details['database']['dbserver_count'])) {
$pluralize = $environment_details['database']['dbserver_count'] > 1 ? 's' : '';
$db_detail = $environment_details['database']['dbserver_count'] . ' db container' . $pluralize;
if (isset($environment_details['database']['read_replication_enabled'])) {
$db_detail .= ' with ' . ($environment_details['database']['read_replication_enabled'] ? 'replication enabled' : 'replication disabled');
}
$details_html[] = $db_detail;
}
if (!empty($details_html)) {
$details_html = '<em>' . esc_html__('Environment Details', 'pantheon-hud') . '</em><br /> - ' . implode('<br /> - ', $details_html);
$wp_admin_bar->add_node(array('id' => 'pantheon-hud-environment-details', 'parent' => 'pantheon-hud', 'title' => $details_html));
}
}
if ($name && $env) {
$wp_cli_stub = sprintf('terminus wp --site=%s --env=%s', $name, $env);
$wp_admin_bar->add_node(array('id' => 'pantheon-hud-wp-cli-stub', 'parent' => 'pantheon-hud', 'title' => '<em>' . esc_html__('WP-CLI via Terminus', 'pantheon-hud') . '</em><br /><input value="' . esc_attr($wp_cli_stub) . '">'));
}
if ($site_id && $env) {
$dashboard_link = sprintf('https://dashboard.pantheon.io/sites/%s#%s/code', $site_id, $env);
$wp_admin_bar->add_node(array('id' => 'pantheon-hud-dashboard-link', 'parent' => 'pantheon-hud', 'href' => $dashboard_link, 'title' => esc_html__('Visit Pantheon Dashboard', 'pantheon-hud'), 'meta' => array('target' => '_blank')));
}
}
开发者ID:pantheon-systems,项目名称:pantheon-hud,代码行数:58,代码来源:class-toolbar.php
示例4: parseLayout
function parseLayout()
{
global $CONFIG;
$api = new API(&$this->pdo);
if (!$this->layoutAlreadyParsed && $this->layoutReadyForParsing) {
require_once $CONFIG["ContentDir"] . "layouts/" . $this->currentLayoutName . ".php";
$this->pdo->insertIntoBodyBuffer($api->getBufferContent());
}
}
开发者ID:BackupTheBerlios,项目名称:twonineothree-svn,代码行数:9,代码来源:layoutManager.php
示例5: index
public function index($data)
{
$api = new API($_SERVER["REQUEST_URI"]);
if (isset($_SESSION["user"])) {
$this->getDate();
} else {
return array("page" => $api->user->auth(), "path" => "/content/" . $api->template . "/", "menu" => $api->getMenu(), "active" => $api->link);
}
}
开发者ID:garmayev,项目名称:public_html,代码行数:9,代码来源:Journal.php
示例6: checkAuth
/**
* Validate the provided API key.
*/
public function checkAuth()
{
$api = new API();
$api->key = $_GET['key'];
try {
$api->validate_key();
} catch (Exception $e) {
json_error($e->getMessage());
die;
}
}
开发者ID:CodeforHawaii,项目名称:statedecoded,代码行数:14,代码来源:class.BaseAPIController.inc.php
示例7: loadFile
protected function loadFile($url)
{
$api = new API($url, false);
$photos = simplexml_load_string(utf8_decode($api->response()));
//charset fix
$res = array();
foreach ($photos as $photo) {
$res[] = array("urlPage" => "http://pix/photo/" . $photo->id, "imgThumb" => "http://pix/media/photo/thumb/" . $photo->author->id . "/" . $photo->link, "imgFull" => "http://pix/media/photo/view/" . $photo->author->id . "/" . $photo->link, "title" => htmlspecialchars($photo->title . " par " . $photo->author->name . " " . $photo->author->surname), "text" => htmlspecialchars($photo->title . " par " . $photo->author->name . " " . $photo->author->surname) . "<br/><a href='http://pix/photo/" . $photo->id . "'>voir dans piX</a>");
}
return $res;
}
开发者ID:netixx,项目名称:frankiz,代码行数:11,代码来源:pix.php
示例8: sendDataToCarrier
/**
* Function send data to DPD API about carrier pickup
*/
private function sendDataToCarrier()
{
$api = new API();
$parameters = array('action' => 'dpdis/pickupOrdersSave', 'payerName' => Configuration::get(DynamicParcelDistribution::CONST_PREFIX . 'PICKUP_ADDRESS_NAME'), 'senderName' => Configuration::get(DynamicParcelDistribution::CONST_PREFIX . 'PICKUP_ADDRESS_NAME'), 'senderAddress' => Configuration::get(DynamicParcelDistribution::CONST_PREFIX . 'PICKUP_ADDRESS_STREET'), 'senderPostalCode' => Configuration::get(DynamicParcelDistribution::CONST_PREFIX . 'PICKUP_ADDRESS_ZIP'), 'senderCountry' => $this->context->language->iso_code, 'senderCity' => Configuration::get(DynamicParcelDistribution::CONST_PREFIX . 'PICKUP_ADDRESS_CITY'), 'senderContact' => Configuration::get(DynamicParcelDistribution::CONST_PREFIX . 'PICKUP_ADDRESS_NAME'), 'senderPhone' => Configuration::get(DynamicParcelDistribution::CONST_PREFIX . 'PICKUP_ADDRESS_PHONE'), 'parcelsCount' => Tools::getValue('Po_parcel_qty'), 'palletsCount' => Tools::getValue('Po_pallet_qty'), 'nonStandard' => Tools::getValue('Po_remark'));
$responce = $api->postData($parameters);
if (strip_tags($responce) == 'DONE') {
$this->context->cookie->__set('redirect_success', Tools::displayError($this->l('Call courier success')));
} else {
$this->context->cookie->__set('redirect_errors', Tools::displayError($this->l('Call courier error: ' . strip_tags($responce))));
}
Tools::redirectAdmin('?controller=AdminOrders&token=' . Tools::getValue('parentToken'));
}
开发者ID:uab-balticode,项目名称:dpd-shipping-module-prestashop-2,代码行数:15,代码来源:AdminCallcarrierController.php
示例9: get_Categories
function get_Categories($subj_ID, $Types)
{
$API = new API();
$found = "";
if (isset($API->get_all_category_for_subject($subj_ID, $Types)['result'])) {
$Materials = $API->get_all_category_for_subject($subj_ID, $Types)['result'];
foreach ($Materials as $material) {
$found = $found . '<li><a href="#"><strong style="color: dimgray">' . $material['category'] . '</strong></a>' . get_Material_Lists($subj_ID, $material['category']) . '</li>';
}
$found = '<ul>' . $found . '</ul>';
}
return $found;
}
开发者ID:samija,项目名称:Content-Management-System,代码行数:13,代码来源:tutorial.php
示例10: render
public function render($template, $data=true)
{
$data=$this->createView($data);
return $this->m->render("{{# render}}$template{{/ render}}",[
'session'=>[
'debug'=>DEBUG,
'hc'=>
$this->api->estAuthentifier()?
$this->api->compteConnecte()->contraste:
false,
'pages'=>$this->api->API_pages_lister(),
'compte'=>$this->api->compteConnecte(),
'estAuthentifier'=>$this->api->estAuthentifier(),
'estAdministrateur'=>$this->api->estAdmin(),
'estDesactive'=>$this->api->estDésactivé(),
'estLibreService'=>$this->api->estLibreService(),
'estNouveau'=>$this->api->estNouveau(),
//'estPanier'=>$this->api->estPanier(),
//'estPremium'=>$this->api->estPremium(),
'peutCommander'=>$this->api->peutCommander(),
'peutModifierCommande'=>function($value){
return $this->api->peutModifierCommande($value);
}
],
'data'=>$data
]);
}
开发者ID:RomLAURENT,项目名称:Jar2Fer,代码行数:28,代码来源:layout.php
示例11: import
/**
* Import template screens.
*
* @param array $allScreens
*
* @return void
*/
public function import(array $allScreens)
{
$screensToCreate = array();
$screensToUpdate = array();
foreach ($allScreens as $template => $screens) {
// TODO: select all at once out of loop
$dbScreens = DBselect('SELECT s.screenid,s.name FROM screens s WHERE' . ' s.templateid=' . zbx_dbstr($this->referencer->resolveTemplate($template)) . ' AND ' . dbConditionString('s.name', array_keys($screens)));
while ($dbScreen = DBfetch($dbScreens)) {
$screens[$dbScreen['name']]['screenid'] = $dbScreen['screenid'];
}
foreach ($screens as $screen) {
$screen = $this->resolveScreenReferences($screen);
if (isset($screen['screenid'])) {
$screensToUpdate[] = $screen;
} else {
$screen['templateid'] = $this->referencer->resolveTemplate($template);
$screensToCreate[] = $screen;
}
}
}
if ($this->options['templateScreens']['createMissing'] && $screensToCreate) {
API::TemplateScreen()->create($screensToCreate);
}
if ($this->options['templateScreens']['updateExisting'] && $screensToUpdate) {
API::TemplateScreen()->update($screensToUpdate);
}
}
开发者ID:SandipSingh14,项目名称:Zabbix_,代码行数:34,代码来源:CTemplateScreenImporter.php
示例12: put_login
public function put_login()
{
$auth = API::post(array('auth', 'login'), Input::all());
if ($auth->code == 400) {
return Redirect::to(prefix('admin') . 'auth/login')->with('errors', new Messages($auth->get()))->with_input('except', array());
}
}
开发者ID:reith2004,项目名称:admin,代码行数:7,代码来源:auth.php
示例13: create
public function create()
{
$companies = Company::where("user_id", Auth::user()->id)->get();
if (\KodeInfo\Utilities\Utils::isDepartmentAdmin(Auth::user()->id)) {
$department_admin = DepartmentAdmins::where('user_id', Auth::user()->id)->first();
$this->data['department'] = Department::where('id', $department_admin->department_id)->first();
$this->data["company"] = Company::where('id', $this->data['department']->company_id)->first();
$this->data['operators'] = API::getDepartmentOperators($department_admin->department_id);
} elseif (\KodeInfo\Utilities\Utils::isOperator(Auth::user()->id)) {
$department_admin = OperatorsDepartment::where('user_id', Auth::user()->id)->first();
$this->data['department'] = Department::where('id', $department_admin->department_id)->first();
$this->data["company"] = Company::where('id', $this->data['department']->company_id)->first();
$this->data['operator'] = User::where('id', $department_admin->user_id)->first();
} else {
$this->data['departments'] = [];
$this->data['operators'] = [];
if (sizeof($companies) > 0) {
$company_departments = API::getCompanyDepartments($companies[0]->id);
if (sizeof($company_departments) > 0) {
$this->data['departments'] = $company_departments;
$this->data['operators'] = API::getDepartmentOperators($company_departments[0]->id);
}
}
$this->data["companies"] = $companies;
}
return View::make('canned_messages.create', $this->data);
}
开发者ID:noikiy,项目名称:Xenon-Support-Center,代码行数:27,代码来源:CannedMessagesController.php
示例14: testEmptyTag
public function testEmptyTag()
{
$json = API::getItemTemplate("book");
$json->tags[] = array("tag" => "", "type" => 1);
$response = API::postItem($json);
$this->assert400($response);
}
开发者ID:robinpaulson,项目名称:dataserver,代码行数:7,代码来源:TagTest.php
示例15: checkAuthentication
public static function checkAuthentication($sessionId)
{
try {
if ($sessionId !== null) {
self::$data = API::User()->checkAuthentication(array($sessionId));
}
if ($sessionId === null || empty(self::$data)) {
self::setDefault();
self::$data = API::User()->login(array('user' => ZBX_GUEST_USER, 'password' => '', 'userData' => true));
if (empty(self::$data)) {
clear_messages(1);
throw new Exception();
}
$sessionId = self::$data['sessionid'];
}
if (self::$data['gui_access'] == GROUP_GUI_ACCESS_DISABLED) {
throw new Exception();
}
self::setSessionCookie($sessionId);
return $sessionId;
} catch (Exception $e) {
self::setDefault();
return false;
}
}
开发者ID:TonywalkerCN,项目名称:Zabbix,代码行数:25,代码来源:CWebUser.php
示例16: checkAuthentication
public static function checkAuthentication($sessionid)
{
try {
if ($sessionid !== null) {
self::$data = API::User()->checkAuthentication($sessionid);
}
if ($sessionid === null || empty(self::$data)) {
self::setDefault();
self::$data = API::User()->login(array('user' => ZBX_GUEST_USER, 'password' => '', 'userData' => true));
if (empty(self::$data)) {
clear_messages(1);
throw new Exception();
}
$sessionid = self::$data['sessionid'];
}
if (self::$data['gui_access'] == GROUP_GUI_ACCESS_DISABLED) {
error(_('GUI access disabled.'));
throw new Exception();
}
zbx_setcookie('zbx_sessionid', $sessionid, self::$data['autologin'] ? time() + SEC_PER_DAY * 31 : 0);
return true;
} catch (Exception $e) {
self::setDefault();
return false;
}
}
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:26,代码来源:class.cwebuser.php
示例17: action_render
public function action_render()
{
$availableChannelTypesJson = API::channel_api()->list_available_channel_types();
$availableChannelTypes = json_decode($availableChannelTypesJson);
$channelTypesArray = $availableChannelTypes->data->channelTypes;
$channelsJson = API::channel_api()->get_all_channels();
$channels = json_decode($channelsJson);
$channelsArray = $channels->data->channels;
$return;
$return->channelTypes = array();
foreach ($channelTypesArray as $channelType) {
$t->type = $channelType->type;
$t->subTypes = array();
foreach ($channelType->subTypes as $subType) {
$st->type = $subType;
$st->sources = array();
foreach ($channelsArray as $source) {
if ($source->type != $t->type || $source->subType != $st->type) {
continue;
}
$c->name = $source->name;
$c->id = $source->id;
$st->sources[] = $c;
unset($c);
}
$t->subTypes[] = $st;
unset($st);
}
$return->channelTypes[] = $t;
unset($t);
}
$this->template->channels = $return;
}
开发者ID:katembu,项目名称:Swiftriver,代码行数:33,代码来源:channeltree.php
示例18: getImageByIdent
function getImageByIdent($ident)
{
zbx_value2array($ident);
if (!isset($ident['name'])) {
return 0;
}
static $images;
if (is_null($images)) {
$images = array();
$dbImages = API::Image()->get(array('output' => array('imageid', 'name'), 'nodeids' => get_current_nodeid(true)));
foreach ($dbImages as $image) {
if (!isset($images[$image['name']])) {
$images[$image['name']] = array();
}
$nodeName = get_node_name_by_elid($image['imageid'], true);
if (!is_null($nodeName)) {
$images[$image['name']][$nodeName] = $image;
} else {
$images[$image['name']][] = $image;
}
}
}
$ident['name'] = trim($ident['name'], ' ');
if (!isset($images[$ident['name']])) {
return 0;
}
$searchedImages = $images[$ident['name']];
if (!isset($ident['node'])) {
return reset($searchedImages);
} elseif (isset($searchedImages[$ident['node']])) {
return $searchedImages[$ident['node']];
} else {
return 0;
}
}
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:35,代码来源:ident.inc.php
示例19: footer
static function footer()
{
$me = API::me();
?>
<script>
$(document).ready(function() {
<?php
if ($me) {
?>
DreamSparkSSO.User = {
accountName: "<?php
echo $me['userPrincipalName'];
?>
",
displayName: "<?php
echo $me['displayName'];
?>
",
imgSrc: "<?php
echo isset($me['thumbnailPhoto']) ? $me['thumbnailPhoto'] : "";
?>
"
};
<?php
}
?>
DreamSparkSSO.AppLauncher.Load("#header");
});
</script>
</body>
</html>
<?php
}
开发者ID:PickeledMarcuz,项目名称:DreamSpark-SSO,代码行数:33,代码来源:base.php
示例20: delete
public function delete()
{
$_api = new API();
$_requestHeaders = $_api->manageHeaders(array($this->authHeader));
$_requestPrepare = $_api->prepareRequest('DELETE');
$_url = $this->constants['SERVICE_ENTRY_POINT'] . $this->constants['SERVICE_VERSION'] . '/' . $this->typeOfService . '/' . $this->processId . '/delete';
try {
$_scc = stream_context_create($_requestPrepare);
$_response = @file_get_contents($_url, false, $_scc);
} catch (Exception $e) {
throw new Exception('HTTP request failed.');
}
$http_response_header = isset($http_response_header) ? $http_response_header : array();
$_validatedResponse = $_api->validateParams('GET_PROCESS_STATUS', $http_response_header, $_response);
return $_validatedResponse;
}
开发者ID:copyleaks,项目名称:php-plagiarism-checker,代码行数:16,代码来源:CopyleaksProcess.php
注:本文中的API类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论