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


PHP API::post方法代码示例

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


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

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

示例2: API

<?php

require 'common.php';
require '../includes/classes/API.php';
header("Access-Control-Allow-Origin: *");
$sql->options['error_handling'] = 'die';
$api = new API();
$api->post('/donation/add', function () {
    global $QUERY;
    if (isset($QUERY['created_at']) and $QUERY['created_at']) {
        $QUERY['created_at'] = date("Y-m-d", strtotime($QUERY['created_at']));
    } else {
        $QUERY['created_at'] = date('Y-m-d H:i:s');
    }
    if (isset($QUERY['donation_type']) and $QUERY['donation_type'] == 'gg') {
        $QUERY['donation_type'] = 'globalgiving';
    }
    $donations = new Donation();
    $donation_id = $donations->add($QUERY);
    if ($donation_id) {
        showSuccess("Donation inserted succesfully : Donation ID '.{$donation_id}.'", array("donation" => array("id" => $donation_id)));
    } else {
        showError("Failure in insterting dontaion at server. Try again after some time.");
    }
});
$api->get('/donation/get_donations_for_approval/{poc_id}', function ($poc_id) {
    $donation = new Donation();
    $donations_for_approval = $donation->getDonationsForApproval($poc_id);
    if ($donations_for_approval) {
        showSuccess(count($donations_for_approval) . " donation(s) waiting for approval", array('donations' => $donations_for_approval));
    } else {
        $error = $donation->error;
开发者ID:makeadiff,项目名称:exdon,代码行数:32,代码来源:index.php

示例3: testListWithPaginate

 public function testListWithPaginate()
 {
     $test = new API($this);
     for ($i = 1; $i <= 10; $i++) {
         $test->post('/posts', '{"user_id":"1","category_id":"1","content":"#' . $i . '"}');
         $test->expect(4 + $i);
     }
     $test->get('/posts?page=2,2&order=id');
     $test->expect('{"posts":{"columns":["id","user_id","category_id","content"],"records":[["5","1","1","#1"],["6","1","1","#2"]],"results":12}}');
 }
开发者ID:4nn4bel,项目名称:mysql-crud-api,代码行数:10,代码来源:tests.php

示例4: testErrorOnFailingForeignKeyConstraint

 public function testErrorOnFailingForeignKeyConstraint()
 {
     $test = new API($this);
     $test->post('/posts', '{"user_id":"3","category_id":"1","content":"fk constraint"}');
     $test->expect('null');
 }
开发者ID:amanullah-1,项目名称:php-crud-api,代码行数:6,代码来源:tests.php

示例5: API

// Load Composer autoload file
include "../vendor/autoload.php";
$platforms = ["oauth1" => ["twitter"], "oauth2" => ["facebook"]];
$fakeSessionID = "fakesessionid";
$http = new API();
if (isset($_GET["platform"])) {
    $platform = $_GET["platform"];
    // If OAuth 1 use oauth_token + oauth_verifier
    if (in_array($platform, $platforms["oauth1"])) {
        $code = "{$_GET["oauth_token"]}:{$_GET["oauth_verifier"]}";
        // If OAuth 2 use code + state
    } else {
        $code = "{$_GET["code"]}:{$_GET["state"]}";
    }
    $authDetails = $http->post("/v1/auth/social", ["session_id" => $fakeSessionID, "code" => $code, "platform" => $platform]);
    if ($authDetails) {
        $auth = $http->post("/v1/auth", ["client_id" => "oauthclientid", "client_secret" => "blahblahblah", "grant_type" => "password", "username" => $authDetails->user_id, "password" => $authDetails->token]);
    }
    var_dump($auth);
} else {
    $socialLoginUrls = $http->get("/v1/auth/social/urls", ["session_id" => $fakeSessionID]);
    ?>

    <h1>Logins</h1>

    <ul>
    <?php 
    foreach ($socialLoginUrls as $platform => $url) {
        ?>
        <li><a href="<?php 
开发者ID:smallhadroncollider,项目名称:social-login,代码行数:30,代码来源:index.php

示例6: failed

        if ($value != $expected) {
            failed("{$testName} - Expected '{$expected}', Got: '{$value}'");
        } else {
            logMessage("  Passed: {$testName} - value '{$value}'");
        }
    }
}
$API = new API();
echo "\nStarting Tests...\n";
$Warren = array('firstname' => 'Warren', 'lastname' => 'Sharpe', 'address' => '890 Fake Street', 'city' => 'Dennington', 'state' => 'Victoria', 'postcode' => 3280);
$Bradly = array('firstname' => 'Bradly', 'lastname' => 'Sharpe', 'address' => '123 Fake Street', 'city' => 'Dennington', 'state' => 'Victoria', 'postcode' => 3280);
$Car = array('owner' => null, 'make' => 'Holden Commodore', 'model' => 'VE Wagon', 'registration' => rand(100, 999) . 'XYZ');
/*
 Create Customer - Warren
*/
$result = $API->post('customer', $Warren, "Creating Warren");
if ($result->error) {
    failed("Didn't return customer: " . $result->message . "\n" . json_encode($result->data));
}
foreach ($Warren as $key => $value) {
    $API->test($result->data->{$key}, $value, $key);
}
$Warren['id'] = $result->data->id;
/*
 Create Customer - Bradly
*/
$result = $API->post('customer', $Bradly, "Creating Bradly");
if ($result->error) {
    failed("Didn't return customer: " . $result->message . "\n" . json_encode($result->data));
}
foreach ($Bradly as $key => $value) {
开发者ID:BradlySharpe,项目名称:Sharpies-Auto-Services,代码行数:31,代码来源:Tests.php

示例7: function

/* API root
 **********************************************************************************************************************/
$app->get('/', function () use($app) {
    $app->render_json(["message" => "SoccerWars API v0.1"]);
});
/* Check login credentials
 **********************************************************************************************************************/
$app->post('/login', function () use($app) {
    $data = json_decode($app->request->getBody(), true);
    if ($user_id = User::Login($data['email'], $data['password'])) {
        $user = User::Get($user_id);
        // Activate account if it's the first login and forbid inactive accounts
        if ($user->status == 'pending') {
            $user->setStatus('active');
        } else {
            if ($user->status != 'active') {
                throw new Exception("This account is not active", 401);
            }
        }
        // Return data
        $app->render_json(['name' => $user->name, 'avatar' => $user->avatar, 'token' => $user->getToken()]);
    } else {
        throw new Exception("Invalid credentials", 401);
    }
});
/* Password reset
 **********************************************************************************************************************/
$app->post('/login/reset', function () use($app) {
    $data = json_decode($app->request->getBody(), true);
    $email = $data['email'];
    $captcha = $data['captcha'];
    if (!$email || !filter_var($email, FILTER_VALIDATE_EMAIL)) {
开发者ID:andrecosta,项目名称:SoccerWars,代码行数:32,代码来源:index.php


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