Esempio n. 1
0
<?php

include "fbapp.php";
class SampleApp extends FacebookApp
{
    public function forward_page()
    {
        // welcome.incの内容はご用意ください。
        echo file_get_contents('./welcome.inc');
    }
    public function forward_liked_page()
    {
        // like-welcome.incの内容はご用意ください。
        echo file_get_contents('./like-welcome.inc');
    }
}
$app = new SampleApp('appid', 'secret');
$app->forward($_POST['signed_request']);
Esempio n. 2
0
<?php

// Step 1: Require the Monty bootstrap file
require "../../monty/bootstrap.php";
// Step 2: Define these constants
define('APP_WWW', dirname(__FILE__));
define('APP_DIR', dirname(APP_WWW));
define('APP_LIB', APP_DIR . DS . 'phplib');
define('APP_TPL', APP_DIR . DS . 'templates');
define('APP_SCHEMA', APP_DIR . DS . 'schema');
define('APP_ENV', isset($_ENV['APP_ENV']) ? $_ENV['APP_ENV'] : 'development');
// Optional: Do any config ovrrides!
ini_set("log_errors", "1");
ini_set("display_errors", "0");
// Step 4. Create an instance of your application
$app = new SampleApp(array('database' => array('user' => 'root', 'password' => 'monty', 'host' => 'localhost', 'database' => 'monty')));
// Step 5. SERVE!
$app->serve($_SERVER, $_GET, $_POST);
Esempio n. 3
0
    public function createUser()
    {
        App42API::initialize("API KEY", "SECRET KEY");
        $response = null;
        // FOR  Test Create USER
        $objUser = App42API::buildUserService();
        try {
            print " Starting User Creation test";
            $response = $objUser->createUser("admin", "test", "*****@*****.**");
        } catch (App42BadParameterException $ex) {
            // Exception Caught
            // Check if User already Exist by checking app error code
            if ($ex->getAppErrorCode() == 2001) {
                // Do exception Handling for Already created User.
            }
        } catch (App42SecurityException $ex) {
            // Exception Caught
            // Check for authorization Error due to invalid Public/Private Key
            if ($ex->getAppErrorCode() == 1401) {
                // Do exception Handling here
            }
        } catch (App42Exception $ex) {
            // Exception Caught due to other Validation
        }
        // Render the JSON response. This will return the Successful created
        // User response
    }
}
$SampleAppObj = new SampleApp();
// Call to create User
$SampleAppObj->createUser();
Esempio n. 4
0
<?php

require 'vendor/autoload.php';
use Dynamo\WebApp, Dynamo\HttpRequest, Dynamo\HttpResponse;
class SampleApp extends WebApp
{
    public function config()
    {
        $this->injector->provide('logger', function () {
            return function ($msg) {
                file_put_contents('php://stderr', $msg . PHP_EOL);
            };
        });
        $this->register(new Dynamo\Middleware\RequestDuration());
        $this->register(new Dynamo\Middleware\CORS(['http://localhost:8080']));
        $this->register(new Dynamo\Middleware\Directory('src'));
        $this->register(function ($logger, HttpRequest $request, HttpResponse $response) {
            yield;
            $logger(sprintf('[%s] url: %s response: %d', (new \DateTime())->format(\DateTime::W3C), $request->getUrl(), $response->getStatus()));
        });
        $this->router->get('/', function (HttpResponse $response) {
            $response->setBody('Hello, world!');
        });
    }
}
SampleApp::create()->run()->send();