本文整理汇总了PHP中Game::loadGame方法的典型用法代码示例。如果您正苦于以下问题:PHP Game::loadGame方法的具体用法?PHP Game::loadGame怎么用?PHP Game::loadGame使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Game
的用法示例。
在下文中一共展示了Game::loadGame方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* PAGE: index
* This method handles what happens when you move to http://yourproject/home/index (which is the default page btw)
*/
public function index()
{
$redirected = false;
//check if there is an error
if ($_GET['error'] != '') {
//load error page!
die("<h1>Whoops, something went wrong, you can refresh to see if it fixes it otherwise check back later.</h1>");
}
if (isset($_GET['appSource'])) {
$redirected = true;
$appSource = (int) $_GET['appSource'];
}
if (!$redirected) {
if (isset($_GET['id']) && $_GET['id'] != "") {
$extraParameters['id'] = $_GET['id'];
}
if (isset($_GET['fbSource'])) {
$extraParameters['appSource'] = $_GET['appSource'];
}
if (isset($_GET['traffic_source']) && $_GET['traffic_source'] != '') {
$extraParameters['traffic_source'] = $_GET['traffic_source'];
}
}
$signedRequest = null;
if (isset($_POST['signed_request'])) {
$signedRequest = self::parseSignedRequest($_POST['signed_request']);
}
Log::add('Signed request: ' . $signedRequest);
//check if user_id
if ($signedRequest === null) {
//we need to get one!
$url = Config::get('facebook.appurl') . "?" . http_build_query($_GET);
header("location: " . $url);
exit;
}
if (!isset($signedRequest['user_id']) || $signedRequest['user_id'] == '') {
$redirectUrl = self::buildUrl($extraParameters);
$oAuthUrl = "https://www.facebook.com/dialog/oauth?";
$oAuthUrl .= http_build_query(array_filter(array('client_id' => Config::Get('facebook.appid'), 'redirect_uri' => self::buildUrl($extraParameters), 'scope' => 'user_friends,email')));
die("<script>top.location.href = '" . $oAuthUrl . "';</script>");
}
$fbCurlReq = new Curl();
$fbCurlReq->setOpt(CURLOPT_SSL_VERIFYPEER, false);
$fbCurlReq->get('https://graph.facebook.com/me?access_token=' . $signedRequest['oauth_token']);
if ($fbCurlReq->error) {
Log::add('Error fb user profile ' . $fbCurlReq->error_code . ': ' . $fbCurlReq->error_message);
} else {
$dataArray = $fbCurlReq->response;
}
Log::add('dataArray = ' . print_r($dataArray, true));
//check too see if this is a post :)
$game = new Game();
$game->loadGame((array) $dataArray, 'facebook', $extraParameters);
}
示例2: index
public function index()
{
list($loggedIn, $userData) = self::isSignedIn($_GET);
//load! else redir.
if ($loggedIn) {
$dataArray['first_name'] = $userData['gamerName'];
$dataArray['platform'] = 'yahoo';
$dataArray['last_name'] = '';
$dataArray['profileImg'] = $userData['userAvatar'];
$dataArray['id'] = $userData['userId'];
$dataArray['apiToken'] = $userData['apiToken'];
$dataArray['userToken'] = $_GET['usertoken'];
$game = new Game();
$game->loadGame($dataArray, 'yahoo', $_GET);
} else {
$getParams = http_build_query($_GET);
//well lets log them in.
include APP_PATH . 'views/yahoo-login.php';
die;
}
}
示例3: Exception
<?php
require_once "lib/load.php";
if (!require_params("id", "action")) {
die;
}
$action = $_REQUEST["action"];
$game = Game::loadGame($_REQUEST["id"]);
switch ($action) {
case 'up':
case 'down':
case 'left':
case 'right':
echo json_encode($game->move($action));
break;
default:
throw new Exception("Unknown action.");
break;
}