• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Api类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: run

 public function run()
 {
     $reqId = (int) $this->httpRequest->postData('id');
     $reqsData = json_decode($this->httpRequest->postData('data'), true);
     if (json_last_error() !== JSON_ERROR_NONE) {
         //Try with stripslashes()
         $reqsData = json_decode(stripslashes($this->httpRequest->postData('data')), true);
         if (json_last_error() !== JSON_ERROR_NONE) {
             $errMsg = '#' . json_last_error();
             if (function_exists('json_last_error_msg')) {
                 $errMsg .= ' ' . json_last_error_msg();
             }
             throw new \RuntimeException('Malformed JSON-encoded request (' . $errMsg . ')', 400);
         }
     }
     $responses = array();
     foreach ($reqsData as $requestData) {
         $apiCall = new Api();
         $apiCall->emulate($requestData, $this->httpRequest);
         $apiCall->run();
         $responses[] = $apiCall->httpResponse()->content();
     }
     $resp = new ApiGroupResponse();
     $resp->setResponses($responses);
     $resp->setId($reqId);
     $this->httpResponse->addHeader('Content-Type: application/json');
     if ($resp->cacheable()) {
         $this->httpResponse->setCacheable();
     }
     $this->httpResponse->setContent($resp);
 }
开发者ID:Rudi9719,项目名称:stein-syn,代码行数:31,代码来源:ApiGroup.class.php


示例2: run

 public function run()
 {
     if (!$this->_canRun) {
         return;
     }
     $channelId = $this->_getChannel();
     $option['oldest'] = $this->_getMessageInterval();
     $api = new Api();
     //Get the latest 100 messages in the past minute
     $data = array_merge($option, array('channel' => $channelId, 'inclusive' => 1.0));
     $result = $api->getChannelMessages($data);
     if (!$result->ok || empty($result->messages)) {
         return;
     }
     //Apply filters
     $filteredMessages = $api->filterMessages($result->messages, $this->_wordTriggers, $this->_excludedUsers);
     if (count($filteredMessages)) {
         $userList = new SlackUserCollection();
         $selectedUsers = array();
         foreach ($filteredMessages as $msg) {
             $member = $userList->getMemberById($msg->user);
             $selectedUsers[$member->id] = $userList->getName($member);
         }
         $userStr = implode(', ', $selectedUsers);
         $message = "hey " . $userStr . " " . $this->_getMessage();
         $data = array('channel' => $channelId, 'text' => $message, 'username' => $this->_user, 'parse' => 'full', 'link_names' => 1);
         if ($this->_userIcon) {
             $data['icon_url'] = $this->_userIcon;
         }
         $this->_postMessage($data);
     }
 }
开发者ID:heyqule,项目名称:slackbot,代码行数:32,代码来源:ThatFamily.php


示例3: testCreateUrl

 public function testCreateUrl()
 {
     $expectedUrl = "http://test.webpay.com/foo/csob.do?MERCHANTNUMBER=1234&OPERATION=CREATE_ORDER&ORDERNUMBER=1234&AMOUNT=980&CURRENCY=978&DEPOSITFLAG=0&URL=http%3A%2F%2Ffoo.bar&DIGEST=Y%2BEFNoZgv0N%2B06PkOXe7v6lg4jilLcYKhWA9NDZgh2Y51vRf0Tt5N8KbPqHsWaNXUoDZ598OJgqC5NeG7km%2FiNh29uyQvYQuXaFEjA77QVWUZz6MgrI2VZU7XObyhC%2FETJ5UruAcxgpUAwCnAnWSz374%2BPzkfuS1OHxQEK4UFEam3kns06fbyR2mloa4a6xduiRt9j%2Buy6YXGoe%2FycxrOUfUPug79XZRjF7gmUgAnIvCIUcqD%2BT2mlUmG7BtzuD2pCTyV3RV47lHhO5gLGBN1VFBDm%2BNO6zqM4WTkz9ZtJmsjbzTWX3MEmQgHiiJ9mDd%2FgWY1ipWFWz%2F7TQeZEwctg%3D%3D";
     $request = new PaymentRequest(1234, 9.800000000000001, PaymentRequest::EUR, 0, 'http://foo.bar');
     $api = new Api(1234, 'http://test.webpay.com/foo/csob.do', new Signer(__DIR__ . '/keys/test_key.pem', 'changeit', __DIR__ . '/keys/test_cert.pem'));
     $this->assertEquals($expectedUrl, $api->createPaymentRequestUrl($request));
 }
开发者ID:sajfi,项目名称:gp-webpay-php-sdk,代码行数:7,代码来源:PaymentRequestUrlTest.php


示例4: run

 public function run()
 {
     header('Content-Type: text/xml');
     $api = new Api();
     if ($_GET['operation'] == 'searchRetrieve') {
         echo $api->searchRetrieveRequest($_GET);
     }
 }
开发者ID:onre,项目名称:finna-proxy,代码行数:8,代码来源:App.php


示例5: callHook

function callHook()
{
    global $url;
    global $default;
    global $controller;
    $queryString = array();
    if (!isset($url)) {
        $controller = $default['controller'];
        $action = $default['action'];
    } else {
        $url = routeURL($url);
        $urlArray = array();
        $urlArray = explode("/", $url);
        $urlArray = array_filter($urlArray);
        $controller = $urlArray[0];
        array_shift($urlArray);
        if (isset($urlArray[0])) {
            $action = $urlArray[0];
            array_shift($urlArray);
        } else {
            $action = 'index';
            // Default Action
        }
        $queryString = $urlArray;
    }
    $controllerName = ucfirst($controller) . 'Controller';
    // Check to see if the controller exists
    if (!file_exists('../application/controllers/' . $controllerName . '.php')) {
        if (isset($_SERVER['CONTENT_TYPE']) && $_SERVER['CONTENT_TYPE'] == 'application/json') {
            // Serve up some JSON
            $dispatch = new Api();
            $dispatch->response('Endpoint not found', 404);
        } else {
            // Serve up some HTML
            $dispatch = new ErrorController();
            call_user_func_array(array($dispatch, 'notFound'), []);
            exit;
        }
    }
    $dispatch = new $controllerName($controller, $action);
    if ((int) method_exists($controllerName, $action)) {
        call_user_func_array(array($dispatch, "beforeAction"), $queryString);
        call_user_func_array(array($dispatch, $action), $queryString);
        call_user_func_array(array($dispatch, "afterAction"), $queryString);
    } else {
        // We should check the Accept header type to server up the correct 404
        if (isset($_SERVER['CONTENT_TYPE']) && $_SERVER['CONTENT_TYPE'] == 'application/json') {
            // Serve up some JSON
            $dispatch = new Api();
            $dispatch->response('Endpoint not found', 404);
        } else {
            // Serve up some HTML
            $dispatch = new ErrorController();
            call_user_func_array(array($dispatch, 'notFound'), []);
            exit;
        }
    }
}
开发者ID:rorystandley,项目名称:php-mvc,代码行数:58,代码来源:application.php


示例6: _postMessage

 protected function _postMessage($data)
 {
     if (Setting::DEV_TEST) {
         echo "Posting: {$data['text']} to {$data['channel']} by {$data['username']} \n";
     } else {
         $api = new Api();
         $api->postMessage($data);
     }
 }
开发者ID:heyqule,项目名称:slackbot,代码行数:9,代码来源:ThatBot.php


示例7: buildRequestParaToString

 /**
  * 生成要请求给支付宝的参数数组
  * @param $para_temp 请求前的参数数组
  * @return 要请求的参数数组字符串
  */
 function buildRequestParaToString($para_temp)
 {
     //待请求参数数组
     $para = $this->buildRequestPara($para_temp);
     $api = new Api();
     //把参数组中所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串,并对字符串做urlencode编码
     $request_data = $api->createLinkstringUrlencode($para);
     return $request_data;
 }
开发者ID:ljimmy,项目名称:pay,代码行数:14,代码来源:BaseRequest.php


示例8: getRelatedFromApi

 public static function getRelatedFromApi(Api $api)
 {
     $ret = array();
     $pm = new PolicyManager();
     $am = new AuthManager();
     $allPolicies = $pm->getAllPolicies(true);
     $relatedPolicies = array();
     $policyPropsArr = array();
     $allAuths = $am->getAllAuths(true);
     $relatedAuthIds = array();
     $relatedAuths = array();
     $authPropsArr = array();
     foreach ($allPolicies as $policy) {
         /**
          * @var Policy $policy
          */
         $apiIds = $policy->getApiIds();
         foreach ($apiIds as $apiId) {
             if ($apiId === $api->getId()) {
                 $relatedPolicies[] = $policy;
             }
         }
     }
     foreach ($relatedPolicies as $policy) {
         $props = $policy->getProperties();
         if (!empty($props)) {
             $policyPropsArr[$policy->getId()] = array_keys($props);
         }
         foreach ($policy->getAuthIds() as $authBucket) {
             if ($authBucket && $authBucket->getAuthIds()) {
                 $relatedAuthIds = array_unique(array_merge($relatedAuthIds, $authBucket->getAuthIds()));
             }
         }
     }
     foreach ($allAuths as $auth) {
         /**
          * @var $auth Auth
          */
         if (in_array($auth->getId(), $relatedAuthIds)) {
             $relatedAuths[] = $auth;
         }
     }
     foreach ($relatedAuths as $auth) {
         $props = $auth->getProperties();
         if (!empty($props)) {
             $authPropsArr[$auth->getId()] = array_keys($props);
         }
     }
     if (!empty($policyPropsArr)) {
         $ret["policy"] = $policyPropsArr;
     }
     if (!empty($authPropsArr)) {
         $ret["auth"] = $authPropsArr;
     }
     return json_encode($ret);
 }
开发者ID:kyroskoh,项目名称:apigrove,代码行数:56,代码来源:JsonPropertyPrinter.php


示例9: fire

 protected function fire(InputInterface $input, OutputInterface $output)
 {
     foreach (['username', 'file', 'num'] as $option) {
         if (is_null($input->getOption($option))) {
             throw new Exception("Missing argument: {$option}");
         }
     }
     $username = $input->getOption('username');
     $relationships = $this->getRelationships($username);
     $api = new Api($username);
     $md5 = md5_file(app_path($input->getOption('file')));
     $toFollow = load($input->getOption('file'));
     $num = (int) $input->getOption('num');
     $state = $this->getState($username, $md5);
     $initialPosition = $state->position;
     $this->info("Follow: from account {$username}\t File: {$md5}");
     $this->info(sprintf("Starting from position: {$initialPosition}\t Out of: %s", count($toFollow)));
     $this->info(sprintf("Number to follow: %s", $num));
     $this->info(sprintf("Relationships update for %s: %s", $username, date(DATE_RFC822, $relationships->time->sec)));
     $this->info('-----');
     $n = 0;
     $position = $initialPosition;
     while ($n < $num) {
         if ($position >= count($toFollow)) {
             $this->error('File is over');
             break;
         }
         list($userId, $userSrc) = $toFollow[$position];
         if (in_array($userId, $relationships->followings)) {
             $this->line("Skipped {$userId}\tAlready following");
         } elseif (in_array($userId, $relationships->followers)) {
             $this->line("Skipped {$userId}\tAlready a follower");
         } else {
             if ($input->getOption('force')) {
                 $response = $api->follow($userId);
                 $response = json_decode($response->response);
                 $this->line(sprintf("Followed {$userId} \tsrc: {$userSrc} \t Username: %s", $response->screen_name));
             } else {
                 $this->line("Follow {$userId} \tsrc: {$userSrc}");
             }
             // Store to archive
             $follow = array('username' => $username, 'md5' => $md5, 'time' => new MongoDate(), 'src' => $userSrc, 'userId' => $userId);
             if (isset($response)) {
                 $follow['response'] = $response;
             }
             $this->db->follows->insert($follow);
             // Clean stuff
             unset($response);
             // Increment $n
             $n++;
         }
         // @todo: don't follow previously followed people
         $position++;
     }
     $this->saveState($username, $md5, $position);
 }
开发者ID:julien-c,项目名称:twitter-cli,代码行数:56,代码来源:FollowCommand.php


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


示例11: make_api

 public static function make_api()
 {
     $api = new Api('Cohen', 'hello_world', 'A demo function.');
     $api->add_property('user_name', 'Your Name');
     $api->set_path('cohen.php');
     $apis = array();
     $apis[] = $api;
     $results = array('classname' => 'Cohen', 'apis' => $apis);
     return $results;
 }
开发者ID:jackycgq,项目名称:cohenbible,代码行数:10,代码来源:cohen.php


示例12: run

 public static function run()
 {
     Bootstrap::setup();
     $app = new App();
     if (Util::has_request_param("action")) {
         $api = new Api($app);
         $api->apply();
     } else {
         define("FALLBACK", $app->get_fallback());
         normalized_require_once("page");
     }
 }
开发者ID:WebPassions,项目名称:local,代码行数:12,代码来源:class-bootstrap.php


示例13: testPaymentHasErrorInVerifyPaymentResponse

 /**
  * @expectedException \AdamStipak\Webpay\PaymentResponseException
  */
 public function testPaymentHasErrorInVerifyPaymentResponse()
 {
     $merchantNumber = 123456789;
     $params = ['OPERATION' => 'operation', 'ORDERNUMBER' => 'ordernumber', 'MERORDERNUMBER' => 'merordernum', 'PRCODE' => 1, 'SRCODE' => 2, 'RESULTTEXT' => 'resulttext'];
     $signer = new Signer(__DIR__ . '/keys/test_key.pem', 'changeit', __DIR__ . '/keys/test_cert.pem');
     $digest = $signer->sign($params);
     $params['MERCHANTNUMBER'] = $merchantNumber;
     $digest1 = $signer->sign($params);
     $response = new PaymentResponse($params['OPERATION'], $params['ORDERNUMBER'], $params['MERORDERNUMBER'], $params['PRCODE'], $params['SRCODE'], $params['RESULTTEXT'], $digest, $digest1);
     $api = new Api($merchantNumber, 'http://foo.bar', $signer);
     $api->verifyPaymentResponse($response);
 }
开发者ID:sajfi,项目名称:gp-webpay-php-sdk,代码行数:15,代码来源:ApiTest.php


示例14: fromDeploymentUuid

 public static function fromDeploymentUuid($uuid, $cachePath = '/tmp')
 {
     $sessionBuilder = function ($expt) {
         return new CookieSession($expt->uuid);
     };
     $api = new Api($uuid, '//api.mynaweb.com/');
     $loader = function ($deploymentUuid) use($api) {
         return json_encode($api->getDeployment());
     };
     $cache = new FileCache($cachePath, $loader);
     return new CachingClient($uuid, $sessionBuilder, $cache);
 }
开发者ID:myna,项目名称:myna-php,代码行数:12,代码来源:CachingClient.php


示例15: fire

 protected function fire(InputInterface $input, OutputInterface $output)
 {
     $usernames = $input->getArgument('usernames');
     $api = new Api();
     foreach ($usernames as $username) {
         $followers = $api->followersIds($username);
         $followings = $api->followingsIds($username);
         $this->db->relationships->insert(array('username' => $username, 'time' => new MongoDate(), 'followers' => $followers, 'followings' => $followings));
         if (!$output->isQuiet()) {
             $this->info(sprintf("Synced %s:\t Following %s\t Followers %s", $username, count($followings), count($followers)));
         }
     }
 }
开发者ID:julien-c,项目名称:twitter-cli,代码行数:13,代码来源:SyncCommand.php


示例16: list_serveur

 public function list_serveur()
 {
     $apk = "YLVnWI9vwB5nYEg0";
     $endpoint = "ovh-eu";
     $ask = "bDPjuf931jLDmhMMbTLSfatartv43rzB";
     $csk = "is8M5oyHUJNR7UfxB5ToF6wQWAcMPfxn";
     $ovh = new Api($apk, $ask, $endpoint, $csk);
     $liste_server = array();
     while ($liste_server) {
         $ovh->get("/vps");
     }
     return $liste_server;
 }
开发者ID:CRIDIP-SWD,项目名称:PORTAIL,代码行数:13,代码来源:ovh_wrapper.php


示例17: buildFromCategory

 public function buildFromCategory($categoryTitle)
 {
     $api = new Api($this->lang);
     $response = $api->completeQuery(['generator' => 'categorymembers', 'gcmtitle' => $categoryTitle, 'gcmnamespace' => '0', 'prop' => 'info', 'gcmlimit' => '100']);
     if (!array_key_exists('query', $response)) {
         throw new HttpException('Not Found', 404);
     }
     $pages = $response['query']['pages'];
     $titles = [];
     foreach ($pages as $page) {
         $titles[] = $page['title'];
     }
     return $this->buildFromTitles($titles, $categoryTitle);
 }
开发者ID:jberkel,项目名称:tool,代码行数:14,代码来源:OpdsBuilder.php


示例18: create_token

 /**
  * Creates and returns a new token/api_key combination for the
  * specified user ID. Returns an array with the two values. Note
  * that for an existing user ID, this will generate a new pair,
  * replacing the old values and making them no longer valid for
  * API access.
  */
 public static function create_token($user_id)
 {
     $a = self::query()->where('user_id', $user_id)->single();
     if ($a && !$a->error) {
         $a->token = md5(uniqid(mt_rand(), 1));
         $a->api_key = md5(uniqid(mt_rand(), 1));
     } else {
         $a = new Api(array('token' => md5(uniqid(mt_rand(), 1)), 'api_key' => md5(uniqid(mt_rand(), 1)), 'user_id' => $user_id));
     }
     while (!$a->put()) {
         $a->token = md5(uniqid(mt_rand(), 1));
     }
     return array($a->token, $a->api_key);
 }
开发者ID:Selwyn-b,项目名称:elefant,代码行数:21,代码来源:Api.php


示例19: create_token

 /**
  * Creates and returns a new token/api_key combination for the
  * specified user ID. Returns an array with the two values. Note
  * that for an existing user ID, this will generate a new pair,
  * replacing the old values and making them no longer valid for
  * API access.
  */
 public static function create_token($user_id)
 {
     $a = Api::query()->where('user_id', $user_id)->fetch();
     if (count($a) > 0) {
         $a = $a[0];
         $a->token = md5(uniqid(mt_rand(), 1));
         $a->api_key = md5(uniqid(mt_rand(), 1));
     } else {
         $a = new Api(array('token' => md5(uniqid(mt_rand(), 1)), 'api_key' => md5(uniqid(mt_rand(), 1)), 'user_id' => $user_id));
     }
     while (!$a->put()) {
         $a->token = md5(uniqid(mt_rand(), 1));
     }
     return array($a->token, $a->api_key);
 }
开发者ID:nathanieltite,项目名称:elefant,代码行数:22,代码来源:Api.php


示例20: updateMemberData

 public function updateMemberData($finalPath)
 {
     $fileHandler = fopen($finalPath, 'w');
     $api = new Api();
     $users = $api->getUserList();
     if ($users->ok && $users->members) {
         $sortedMember = array();
         foreach ($users->members as $obj) {
             $sortedMember[$obj->id] = $obj;
         }
         $cacheString = json_encode($sortedMember);
         fputs($fileHandler, $cacheString);
     }
     fclose($fileHandler);
 }
开发者ID:heyqule,项目名称:slackbot,代码行数:15,代码来源:SlackUserCollection.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP ApiAuthAction类代码示例发布时间:2022-05-23
下一篇:
PHP AphrontWriteGuard类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap