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


PHP Api::getInstance方法代码示例

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


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

示例1: api

 public static function api($name = null, $options = array())
 {
     Lib::load('api');
     if (empty($name)) {
         $api = new Api();
         $api->config($options);
         return $api;
     }
     return Api::getInstance($name, $options);
 }
开发者ID:jasonrey,项目名称:project-test-report,代码行数:10,代码来源:lib.php

示例2: getGuardUser

 /**
  * Returns the related sfGuardUser.
  *
  * @return sfGuardUser
  */
 public function getGuardUser()
 {
     if (!$this->user && ($id = $this->getApiUserId())) {
         //$this->user = Doctrine_Core::getTable('sfGuardUser')->find($id);
         $data = Api::getInstance()->get('user/' . $this->_user_id);
         $this->user = ApiDoctrine::createObject('sfGuardUser', $data['body']);
         if (!$this->user) {
             // the user does not exist anymore in the database
             $this->signOut();
             throw new sfException('The user does not exist anymore.');
         }
     }
     return $this->user;
 }
开发者ID:nocoolnametom,项目名称:OpenMicNight,代码行数:19,代码来源:myUser.class.php

示例3: Find

 public function Find($request, $response, $args)
 {
     //userid
     $user_id = Api::getInstance()->getExtra('user_id');
     //get the task id
     $id = $args['id'];
     $data = array('success' => false);
     //fetch task data
     $t = $this->db->task("id = ?", $id)->fetch();
     if ($t) {
         $data = array('success' => true, 'task' => $t);
         //verifier si l'utilisateur courant n'as pas déja choisi cette tache
         $exist = $t->user_task()->fetch();
         if ($exist) {
             $data['task']['accepted'] = $exist['user_id'] == $user_id;
         } else {
             $data['task']['accepted'] = false;
         }
     }
     echo json_encode($data);
     return $response->withHeader('Content-type', 'application/json');
 }
开发者ID:senegalesegirl,项目名称:CrowdHelp,代码行数:22,代码来源:task.php

示例4: getIndexEpisodes

 protected function getIndexEpisodes()
 {
     $subreddit_ids = array();
     $subreddit_data = Api::getInstance()->get('subreddit/defaultfeed', true);
     $subreddits = ApiDoctrine::createQuickObjectArray($subreddit_data['body']);
     foreach ($subreddits as $subreddit) {
         if (!in_array($subreddit->getIncremented(), $subreddit_ids)) {
             $subreddit_ids[] = $subreddit->getIncremented();
         }
     }
     $episodes = array();
     if (count($subreddit_ids)) {
         $episode_data = Api::getInstance()->get('episode/released?nwfw=&subreddit_id=' . implode(',', $subreddit_ids), true);
         $episodes = ApiDoctrine::createObjectArray('Episode', $episode_data['body']);
     }
     return $episodes;
 }
开发者ID:nocoolnametom,项目名称:OpenMicNight,代码行数:17,代码来源:actions.class.php

示例5: processForm

 protected function processForm(sfWebRequest $request, EpisodeForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $form->processValues($form->getValues());
         $auth_key = $this->getUser()->getApiAuthKey();
         if ($form->getValue('id')) {
             // Update existing item.
             $values = $form->getTaintedValues();
             if ($form->getValue('audio_file_delete') == true) {
                 if (!$form->getObject()->getApprovedAt() && !$form->getObject()->getSubmittedAt()) {
                     $values['audio_file'] = null;
                     $values['nice_filename'] = null;
                     $form->getObject()->removeFileFromApplicationBucket($form->getObject()->getAudioFile(), 'audio');
                     unlink(sfConfig::get('sf_data_dir') . '/temp/' . $form->getObject()->getAudioFile());
                 }
             }
             if ($form->getValue('graphic_file_delete') == true) {
                 if (!$form->getObject()->getApprovedAt()) {
                     $values['graphic_file'] = null;
                     $form->getObject()->removeFileFromApplicationBucket($form->getObject()->getGraphicFile(), 'upload');
                     unlink(sfConfig::get('sf_web_dir') . '/uploads/graphics/' . $form->getObject()->getGraphicFile());
                 }
             }
             unset($values['_csrf_token'], $values['id'], $values['graphic_file_delete'], $values['audio_file_delete']);
             $episode = $form->getObject();
             if (!array_key_exists('is_nsfw', $values) && $episode->getIsNsfw()) {
                 $values['is_nsfw'] = 0;
             }
             foreach ($values as $key => $value) {
                 if ($value == "on") {
                     $values[$key] = 1;
                 }
                 if ($value == "off") {
                     $values[$key] = 0;
                 }
             }
             $id = $episode->getId();
             $result = Api::getInstance()->setUser($auth_key)->put('episode/' . $id, $values);
             $success = $this->checkHttpCode($result, 'put', 'episode/' . $id, json_encode($values));
             if ($success) {
                 $this->getUser()->setFlash('notice', 'Episode was saved successfully.');
             }
             $test_episode = ApiDoctrine::createObject('Episode', $result['body']);
             $episode = $test_episode ? $test_episode : $episode;
         }
         $this->redirect('episode/edit?id=' . $episode->getId());
     }
 }
开发者ID:nocoolnametom,项目名称:OpenMicNight,代码行数:49,代码来源:actions.class.php

示例6: processForm

 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $auth_key = $this->getUser()->getApiAuthKey();
         // Update existing item.
         $values = $form->getTaintedValues();
         $user_id = $form->getValue('id') ? $form->getValue('id') : $this->getUser()->getApiUserId();
         unset($values['_csrf_token'], $values['is_active'], $values['password'], $values['password_again'], $values['groups_list'], $values['permissions_list'], $values['is_validated'], $values['reddit_validation_key'], $values['is_authorized'], $values['email_authorization_key'], $values['authorized_at'], $values['is_super_admin'], $values['algorithm'], $values['id'], $values['salt'], $values['last_login']);
         if ($form->getValue('password')) {
             $values['password'] = $form->getValue('password');
         }
         $user_data = Api::getInstance()->get('user/' . $user_id);
         $user = ApiDoctrine::createObject('sfGuardUser', $user_data['body']);
         $user_values = $user->toArray();
         foreach ($values as $key => $value) {
             if ($value == $user_values[$key]) {
                 unset($values[$key]);
             }
         }
         if (array_key_exists('id', $values)) {
             unset($values['id']);
         }
         $id = $this->getUser()->getApiUserId();
         $result = Api::getInstance()->setUser($auth_key)->put('user/' . $id, $values);
         $success = $this->checkHttpCode($result, 'put', 'user/' . $id, json_encode($values));
         if ($success) {
             $this->getUser()->setFlash('notice', 'Profile was edited successfully.');
         }
         $this->redirect('profile');
     }
 }
开发者ID:nocoolnametom,项目名称:OpenMicNight,代码行数:32,代码来源:actions.class.php

示例7: getFullPath

 public function getFullPath()
 {
     return $this->request->getScheme() . "://" . Api::URL . "/" . $this->request->getApi() . "/" . $this->request->getMethodPath() . "/" . Api::getInstance()->getAppKey();
 }
开发者ID:mallerp,项目名称:aliexpress.open,代码行数:4,代码来源:Sign.php

示例8: processForm

 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->getValue('recipient_id') == $this->getUser()->getApiUserId()) {
         $this->getUser()->setFlash('error', 'You cannot sent messages to yourself.');
         $this->redirect('message');
     }
     if ($form->isValid() && $this->getUser()->getApiUserId()) {
         $auth_key = $this->getUser()->getApiAuthKey();
         if ($form->getValue('id')) {
             // Update existing item.
             $values = $form->getObject()->getModified();
             $message = $form->getObject();
             unset($values['id']);
             $id = $form->getValue('id');
             $result = Api::getInstance()->setUser($auth_key)->put('message/' . $id, $values);
             $success = $this->checkHttpCode($result, 'put', 'message/' . $id, json_encode($values));
             if ($success) {
                 $this->getUser()->setFlash('notice', 'Message was edited successfully.');
             }
             $test_message = ApiDoctrine::createObject('Message', $result['body']);
             $message = $test_message ? $test_message : $message;
         } else {
             // Create new item
             $values = $form->getValues();
             $message = $form->getObject();
             foreach ($values as $key => $value) {
                 if (is_null($value)) {
                     unset($values[$key]);
                 }
             }
             if (!array_key_exists('sender_id', $values)) {
                 $values['sender_id'] = $this->getUser()->getApiUserId();
             }
             $result = Api::getInstance()->setUser($auth_key)->post('message', $values);
             $success = $this->checkHttpCode($result, 'post', 'message', json_encode($values));
             if ($success) {
                 $this->getUser()->setFlash('notice', 'Message was sent successfully.');
             }
         }
         if (!$this->getUser()->getApiUserId()) {
             $this->getUser()->setFlash('error', 'You are not logged in!');
         }
         $this->redirect('message');
     }
 }
开发者ID:nocoolnametom,项目名称:OpenMicNight,代码行数:46,代码来源:actions.class.php

示例9: validateUpload

 public function validateUpload($payload, sfWebRequest $request = null)
 {
     if (!$request->hasParameter('id')) {
         throw new sfException('No subreddit given.', 400);
     }
     $this->object = SurbedditTable::getInstance()->find($request->hasParameter('id'));
     if (!$this->object) {
         throw new sfException('Cannot find subreddit.', 404);
     }
     $content_file = $request->getFiles('filename');
     $this->_temporary_file_location = array_key_exists('tmp_name', $content_file) ? $content_file['tmp_name'] : null;
     $this->_nice_filename = array_key_exists('name', $content_file) ? $content_file['name'] : null;
     /* Check that the current user is an admin of the Subreddit or otherwise
      * has permission to upload. */
     $membership_data = Api::getInstance()->setUser($auth_key)->get('subredditmembership?' . 'sf_guard_user_id=' . $this->getUser()->getGuardUser()->getIncremented() . '&subreddit_id=' . $this->object->getIncremented(), true);
     $membership = is_array($membership_data['body']) && array_key_exists(0, $membership_data['body']) ? ApiDoctrine::createQuickObject($membership_data['body'][0]) : null;
     $valid_admin = (bool) ($membership && in_array($membership->getMembership()->getType(), array('admin')));
     if (!$this->getUser()->isSuperAdmin() && !$valid_admin) {
         throw new sfException('Your user does not have permissions to ' . 'upload audio for this Subreddit.', 403);
     }
 }
开发者ID:nocoolnametom,项目名称:OpenMicNight,代码行数:21,代码来源:actions.class.php

示例10: getMethodPath

 /**
  * @return string
  */
 public function getMethodPath()
 {
     return Api::getInstance()->getType() . $this->methodPath;
 }
开发者ID:mallerp,项目名称:aliexpress.open,代码行数:7,代码来源:Request.php

示例11: session_start

include_once 'Api.php';
session_start();
/**
 * This example illustrates how to call the API with very basic CURL calls wrapped in a class.
 * Tested on php5.5.10, apache2.2 ubuntu 12.04
 * @company: Autodata Ltd, UK
 * @author: jakub.wrona@autodata-group.com
 * @date: 2014-04-09 
 */
/**
 * Initialise the api and get a connection.
 * 
 * Here init() takes two paremeters, a client_id and a client_secret.
 * $api is the object to use for all calls from this point on.
 */
$api = Api::getInstance()->init('put your client id string here', 'put your client secret string here');
/**
 * Example 1
 * 
 * Retrieve a list of manufacturers.
 */
$api->setEndpoint('manufacturers');
$response = $api->requestGet(['country-code' => 'gb']);
if ($response !== false) {
    $manufactures = $response->getResponseBody();
    echo 'Example 1, response manufacturers: <br/>';
    echo '<pre>' . print_r($manufactures, 1) . '</pre>';
    echo '<hr />';
}
/**
 * Example 2
开发者ID:amuelle1,项目名称:API-code-samples,代码行数:31,代码来源:api-call.php

示例12: rs_filiado_profile_admin_action

 public function rs_filiado_profile_admin_action()
 {
     $api = Api::getInstance();
     if (isset($_POST) && count($_POST) > 0) {
         $updatedProfile = array('user_id' => $_POST['user_id'], 'tipo' => $_POST['tipo'], 'bandeira' => $_POST['bandeira'], 'cartao_nome' => $_POST['cartao_nome'], 'cartao_numero' => $_POST['cartao_numero'], 'cartao_validade_mes' => $_POST['cartao_validade_mes'], 'cartao_validade_ano' => $_POST['cartao_validade_ano'], 'cartao_codigo_verificacao' => $_POST['cartao_codigo_verificacao'], 'contribuicao' => str_replace(',', '.', $_POST['contribuicao']), 'telefone_residencial' => $_POST['telefone_residencial'], 'telefone_celular' => $_POST['telefone_celular'], 'cep' => $_POST['cep'], 'endereco' => $_POST['endereco'], 'numero' => $_POST['numero'], 'complemento' => $_POST['complemento'], 'bairro' => $_POST['bairro'], 'cidade' => $_POST['cidade'], 'uf' => $_POST['uf'], 'cpf' => $_POST['cpf'], 'fullname' => $_POST['fullname'], 'titulo_eleitoral' => $_POST['titulo_eleitoral'], 'zona_eleitoral' => $_POST['zona_eleitoral'], 'secao_eleitoral' => $_POST['secao_eleitoral'], 'nome_mae' => $_POST['nome_mae'], 'birthday' => $_POST['birthday'], 'sexo' => $_POST['sexo'], 'status' => $_POST['status'], 'contribupdate' => !empty($_POST['tipo']) ? 1 : 0);
         $data = $api->updateProfile($updatedProfile);
     }
     if (isset($data->status) && $data->status == 'ok') {
         $_SESSION['aviso'] = 'Atualizações salvas com sucesso!';
     } else {
         $_SESSION['aviso'] = 'Atualizações não foram realizada, algo está errado, tente novamente mais tarde.';
     }
     wp_redirect($_SERVER['HTTP_REFERER']);
     exit;
 }
开发者ID:rede-sustentabilidade,项目名称:site-wordpress,代码行数:15,代码来源:Filiados.php

示例13: getIndexEpisodes

 protected function getIndexEpisodes()
 {
     $subreddit_ids = array();
     $subreddit_data = Api::getInstance()->get('subreddit/defaultfeed', true);
     $subreddits = ApiDoctrine::createQuickObjectArray($subreddit_data['body']);
     foreach ($subreddits as $subreddit) {
         if (!in_array($subreddit->getIncremented(), $subreddit_ids)) {
             $subreddit_ids[] = $subreddit->getIncremented();
         }
     }
     $episodes = array();
     if (count($subreddit_ids)) {
         $episode_data = Api::getInstance()->get($this->_episode_location . '?subreddit_id=' . implode(',', $subreddit_ids), true);
         $episodes = ApiDoctrine::createQuickObjectArray($episode_data['body']);
     }
     $assignment_ids = array();
     foreach ($episodes as $episode) {
         if (!in_array($episode->getEpisodeAssignmentId(), $assignment_ids)) {
             $assignment_ids[] = $episode->getEpisodeAssignmentId();
         }
     }
     $assignment_data = Api::getInstance()->get('episodeassignment?id=' . implode(',', $assignment_ids), true);
     $assignments = ApiDoctrine::createQuickObjectArray($assignment_data['body']);
     $user_ids = array();
     $this->_assignments = array();
     foreach ($assignments as $assignment) {
         $this->_assignments[$assignment->getIncremented()] = $assignment;
         if (!in_array($assignment->getSfGuardUserId(), $user_ids)) {
             $user_ids[] = $assignment->getSfGuardUserId();
         }
     }
     $user_data = Api::getInstance()->get('user?id=' . implode(',', $user_ids), true);
     $users = ApiDoctrine::createQuickObjectArray($user_data['body']);
     $this->_users = array();
     foreach ($users as $user) {
         $this->_users[$user->getIncremented()] = $user;
     }
     return $episodes;
 }
开发者ID:nocoolnametom,项目名称:OpenMicNight,代码行数:39,代码来源:actions.class.php

示例14: processMembershipForm

 protected function processMembershipForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $auth_key = $this->getUser()->getApiAuthKey();
         if ($form->getValue('id')) {
             // Update existing item.
             $values = $form->getValues();
             $id = $form->getValue('id');
             $membership = $form->getObject();
             $membership_array = $membership->toArray();
             foreach ($membership_array as $key => $value) {
                 if (array_key_exists($key, $values) && $values[$key] == $membership_array[$key]) {
                     unset($values[$key]);
                 }
             }
             if (array_key_exists('display_membership', $values)) {
                 $values['display_membership'] = (bool) $values['display_membership'] ? 1 : 0;
             }
             if (count($values)) {
                 $result = Api::getInstance()->setUser($auth_key)->put('subredditmembership/' . $id, $values);
                 $success = $this->checkHttpCode($result, 'put', 'subredditmembership/' . $id, json_encode($values));
                 if ($success) {
                     $this->getUser()->setFlash('notice', 'Membership was edited successfully.');
                 }
             }
         }
         $this->redirect('subreddit/membership?id=' . $id);
     }
 }
开发者ID:nocoolnametom,项目名称:OpenMicNight,代码行数:30,代码来源:actions.class.php

示例15: validateSubredditForOutroUpload

 protected function validateSubredditForOutroUpload($id, $filename)
 {
     if (is_null($this->getUser()->getAttribute('valid_subreddit', null))) {
         // Base value is false
         $this->getUser()->setAttribute('valid_subreddit', false);
         $subreddit = EpisodeTable::getInstance()->find($id);
         if ($subreddit) {
             // Check if the current user has permission to edit the deadline.
             $membership_data = Api::getInstance()->setUser($auth_key)->get('subredditmembership?sf_guard_user_id=' . $this->getUser()->getApiUserId() . '&subreddit_id=' . $id, true);
             $membership = is_array($membership_data['body']) && array_key_exists(0, $membership_data['body']) ? ApiDoctrine::createQuickObject($membership_data['body'][0]) : null;
             $valid_admin = (bool) ($membership && in_array($membership->getMembership()->getType(), array('admin')));
             if ($valid_admin || $this->getUser()->isSuperAdmin()) {
                 $valid_subreddit = true;
                 $this->getUser()->setAttribute('valid_subreddit', true);
                 $this->getUser()->setAttribute('valid_subreddit_id', $id);
                 $this->getUser()->setAttribute('valid_subreddit_domain', $subreddit->getDomain());
                 $this->getUser()->setAttribute('valid_subreddit_audio_file_hash', $this->generateFilenameHashForSubredditOutro($filename));
                 $subreddit->setEpisodeOutro($this->generateFilenameHashForSubredditOutro($filename));
                 $subreddit->setSkipBackup(true);
                 $subreddit->save();
             }
         }
     }
     return $this->getUser()->getAttribute('valid_subreddit', false);
 }
开发者ID:nocoolnametom,项目名称:OpenMicNight,代码行数:25,代码来源:actions.class.php


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