当前位置: 首页>>代码示例>>PHP>>正文


PHP API::response方法代码示例

本文整理汇总了PHP中API::response方法的典型用法代码示例。如果您正苦于以下问题:PHP API::response方法的具体用法?PHP API::response怎么用?PHP API::response使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在API的用法示例。


在下文中一共展示了API::response方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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

示例2: urlencode

 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

示例3: 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

示例4: run

 public function run()
 {
     global $globals;
     if (!PlCache::hasGlobal('ik')) {
         $ikapi = new API('http://ik.frankiz.net/ajax/last', false);
         $json = json_decode($ikapi->response(), true);
         if (isset($json['ik']['id']) && $json['ik']['id'] != '') {
             $json = $json['ik'];
             $filename = $globals->spoolroot . '/htdocs/data/ik/' . $json['id'] . '.jpg';
             file_put_contents($filename, base64_decode($json['base64']));
             $ik = array('id' => $json['id'], 'title' => $json['title'], 'url' => $json['url']);
             PlCache::setGlobal('ik', $ik, $globals->cache->ik);
         }
     }
     $this->assign('ik', PlCache::getGlobal('ik'));
 }
开发者ID:netixx,项目名称:frankiz,代码行数:16,代码来源:ik.php

示例5: response

 private static function response($destination)
 {
     try {
         $api = new API(self::$urls[$destination]);
         $xml = simplexml_load_string(utf8_decode($api->response()));
         if ($xml && isset($xml->schedules->schedule->liste)) {
             $response = $xml->schedules->schedule->liste->children();
         } else {
             $response = array();
         }
         $return = array();
         foreach ($response as $r) {
             if (preg_match('![0-9]{2}:[0-9]{2}!', (string) $r->texte2)) {
                 $return[] = array('name' => (string) $r->texte3, 'desc' => self::destination((string) $r->texte1), 'time' => (string) $r->texte2);
             }
         }
         return $return;
     } catch (Exception $e) {
         return array();
     }
 }
开发者ID:netixx,项目名称:frankiz,代码行数:21,代码来源:rerloader.php

示例6: response

 private static function response()
 {
     static $url = "http://www.pointgamma.com/moduleFKZ/generation_xml.php";
     try {
         $api = new API($url, true);
         $xml = simplexml_load_string(utf8_decode($api->response()));
         if ($xml) {
             $response = $xml->bars->children();
             $response2 = $xml->annonces->children();
             $response3 = $xml->preventes->children();
         } else {
             $response = array();
             $response2 = array();
             $response3 = array();
         }
         $return = array();
         $bar = array();
         $annonce = array();
         $prevente = array();
         foreach ($response as $r) {
             $bar[] = array('classement' => (string) $r->numero_bar, 'bars' => (string) $r->nom_bar, 'score' => (string) $r->score_bar);
         }
         foreach ($response2 as $r) {
             $annonce[] = array('numero' => (string) $r->numero_annonce, 'titre' => (string) $r->titre_annonce, 'time' => (string) $r->time_annonce, 'text' => (string) $r->text_annonce);
         }
         foreach ($response3 as $r) {
             $prevente[] = array('ecole' => (string) $r->ecole_prevente, 'time' => (string) $r->time_prevente);
         }
         $return[0] = $bar;
         $return[1] = $annonce;
         $return[2] = $prevente;
         return $return;
     } catch (Exception $e) {
         return array();
     }
 }
开发者ID:netixx,项目名称:frankiz,代码行数:36,代码来源:pointg.php

示例7: error

 /**
  * Store an error into the API result, display it and stop script execution
  * 
  * @version 1.0
  * @param   string  $http_response  HTTP Error code to send with JSON
  * @param   string  $code           Error code
  * @param   string  $message        Error message
  * @result  void
  */
 public static function error($http_response, $code, $message)
 {
     // we store error data
     self::$success = false;
     self::$response = $http_response;
     self::$errors[] = array('status' => $http_response, 'code' => $code, 'title' => $message);
     // we parse JSON
     self::parsing();
     // we load JSON result to client
     self::result();
     // we stop script execution
     exit;
 }
开发者ID:leqg,项目名称:leqg-api,代码行数:22,代码来源:api.class.php

示例8: action_delete

 /**
  * Delete field.
  */
 public function action_delete($id)
 {
     // Find field
     $field = CustomField::find($id);
     // Verify project
     if ($field->project_id != $this->project->id) {
         return $this->show_no_permission();
     }
     // Delete and redirect
     $field->delete();
     if ($this->is_api) {
         return \API::response(1);
     } else {
         Request::redirectTo($this->project->href('settings/custom_fields'));
     }
 }
开发者ID:dasklney,项目名称:traq,代码行数:19,代码来源:custom_fields.php

示例9: interaction

 /**
  * Return informations about an interaction
  * 
  * @version 1.0
  * @param   int     $contact        Contact ID
  * @param   int     $id             Interaction ID
  * @return  void
  */
 public function interaction($contact, $id)
 {
     // we search interaction data
     $query = API::query('contact_interaction');
     $query->bindParam(':event', $id, PDO::PARAM_INT);
     $query->bindParam(':contact', $contact, PDO::PARAM_INT);
     $query->execute();
     // we check if wa have an answer
     if ($query->rowCount() == 1) {
         // Yay! we have a contact detail!
         API::response(200);
         // we load contact informations
         $data = $query->fetch(PDO::FETCH_ASSOC);
         // we put contact into links section
         $data['links']['contact'] = $data['contact'];
         API::link('interactions', 'contact', 'contact');
         unset($data['contact']);
         // we put directory data into links section, if exists
         if (!is_null($data['dossier'])) {
             $data['links']['dossier'] = $data['dossier'];
             API::link('interactions', 'dossier', 'dossier');
             unset($data['dossier']);
         } else {
             unset($data['dossier']);
         }
         // we put user data into links section
         $data['links']['utilisateur'] = $data['utilisateur'];
         API::link('interactions', 'utilisateur', 'utilisateur');
         unset($data['utilisateur']);
         // we add contact information to JSON response
         API::add('interactions', $data);
     } else {
         // we display an error
         API::error(404, 'EventUnknown', 'L\'élément d\'historique demandé n\'existe pas.');
     }
 }
开发者ID:leqg,项目名称:leqg-api,代码行数:44,代码来源:contact.class.php

示例10:

<?php

echo API::response(1);
开发者ID:dasklney,项目名称:traq,代码行数:3,代码来源:toggle.json.php

示例11: run

 public function run()
 {
     global $globals;
     // google calendar pour la prochaine émission
     // MAJ 1x/jour
     $gc = "http://www.google.com/calendar/feeds/binet.radio.xray%40gmail.com/public/full?alt=json&orderby=starttime&max-results=50&singleevents=true&sortorder=ascending&futureevents=true";
     // Check if cache needs to be refreshed : if emission < now or if last check was 12h ago
     if (PlCache::hasGlobal('xray_calendar')) {
         $xray_calendar = PlCache::getGlobal('xray_calendar');
         if (!isset($xray_calendar['time']) || !isset($xray_calendar['next_time']) || time() > min($xray_calendar['next_time'], $xray_calendar['time'] + 43200)) {
             PlCache::invalidateGlobal('xray_calendar');
         }
     }
     if (!PlCache::hasGlobal('xray_calendar')) {
         $calendar_api = new API($gc, true);
         $json_calendar = json_decode($calendar_api->response(), true);
         // First emission
         $feed = $json_calendar['feed']['entry'];
         $next_show = "surprise !";
         // Update no-emission every minute
         $next_time = time() + 60;
         for ($i = 0; $i < count($feed); $i++) {
             $entry = $feed[$i];
             $title = $entry['title']['$t'];
             if ($title[0] == '_') {
                 $name = substr($title, 1);
                 $start = new DateTime($entry['gd$when'][0]['startTime']);
                 $next_show = $name . " à " . strftime('%Hh, %A', $start->getTimestamp());
                 $next_time = $start->getTimestamp();
                 break;
             }
         }
         $xray_calendar = array('emission' => $next_show, 'next_time' => $next_time, 'time' => time());
         PlCache::setGlobal('xray_calendar', $xray_calendar, $globals->cache->xray_calendar);
     }
     /*
     
     // feed x-ray pour le dernier podcast
     // MAJ 1x/jour
     $podcasts_xml = "http://x-ray/blog/?feed=podcast";
     
     if (!PlCache::hasGlobal('xray_podcast')) {
         $podcast_api = new API($podcasts_xml, false);
         $podcasts  = $this->xml2array($podcast_api->response());
     
         $last_podcast = $podcasts['rss']['channel']['item'][0];
     
         $xray_podcast = array('titre' => utf8_decode($last_podcast['title']), 'url' => $last_podcast['link'], 'description' => utf8_decode($last_podcast['itunes:subtitle']));
         PlCache::setGlobal('xray_podcast', $xray_podcast, $globals->cache->xray_podcast);
     }
     */
     // titre en cours
     // MAJ toutes les 2 mn
     $nowplaying_xml = "http://x-ray/cache/info.xml";
     if (!PlCache::hasGlobal('xray_nowplaying')) {
         $nowplaying_api = new API($nowplaying_xml, false);
         $nowplaying = $this->xml2array($nowplaying_api->response());
         if (isset($nowplaying['info'])) {
             $song = $nowplaying['info'];
             $xray_nowplaying = array('title' => $song['title'], 'artist' => $song['artist'], 'album' => $song['album'], 'cover' => $song['cover']);
             PlCache::setGlobal('xray_nowplaying', $xray_nowplaying, $globals->cache->xray_nowplaying);
         }
     }
     $this->assign('xray_calendar', PlCache::getGlobal('xray_calendar'));
     //$this->assign('xray_podcast', PlCache::getGlobal('xray_podcast'));
     $this->assign('xray_nowplaying', PlCache::getGlobal('xray_nowplaying'));
 }
开发者ID:netixx,项目名称:frankiz,代码行数:67,代码来源:xray.php

示例12: incidence

 private function incidence()
 {
     //check the current status
     $user_status = $this->status(null, true);
     if ($user_status->status != 'checkin') {
         //the user is not checkedin
         return API::response(array('timestamp' => NULL));
     }
     //incidence
     $incidence = new stdClass();
     $incidence->userid = $this->get_userid($this->_token);
     $incidence->action = 'incidence';
     $incidence->timestamp = time();
     $indicence->computed = 0;
     //store the incidence
     $in_status = DB::putRecord('presence_activity', $incidence);
     //checkout the user
     $checkout = clone $incidence;
     $checkout->action = 'checkout';
     $ch_status = DB::putRecord('presence_activity', $checkout);
     if ($in_status && $ch_status) {
         return API::response(array('timestamp' => $checkout->timestamp));
     } else {
         return API::response(array('timestamp' => NULL));
     }
 }
开发者ID:robertboloc,项目名称:presence-manager,代码行数:26,代码来源:User.php

示例13: array

<?php

echo API::response(0, array('errors' => $field->errors));
开发者ID:dasklney,项目名称:traq,代码行数:3,代码来源:new.json.php

示例14: validateToken

 public function validateToken()
 {
     return \API::response()->array(['status' => 'success'])->statusCode(200);
 }
开发者ID:alaevka,项目名称:rudrone,代码行数:4,代码来源:UserController.php


注:本文中的API::response方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。