Skip to content

Commit

Permalink
Add composer
Browse files Browse the repository at this point in the history
  • Loading branch information
felixklauke committed Jun 24, 2022
1 parent e6db996 commit 84d9eeb
Show file tree
Hide file tree
Showing 21 changed files with 151 additions and 59 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
**/*[Tt]estTitleData.json*

/vendor/
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/playfab-php-sdk.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "dinoscape/playfab-php-sdk",
"type": "library",
"autoload": {
"psr-4": {
"Dinoscape\\PlayfabPhpSdk\\": "src/"
}
},
"authors": [
{
"name": "Felix Klauke",
"email": "felix@klauke-enterprises.com"
}
],
"require": {}
}
3 changes: 3 additions & 0 deletions PlayFabSDK/PlayFabAdminApi.php → src/PlayFabAdminApi.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
namespace PlayFabSDK;

include 'PlayFabHttp.php';

class PlayFabAdminApi
Expand Down Expand Up @@ -1382,4 +1384,5 @@ public static function UpdateUserTitleDisplayName($titleId, $developerSecreteKey
}

}

?>
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php
namespace PlayFabSDK;
use PlayFabHttp;

include 'PlayFabHttp.php';

class PlayFabAuthenticationApi
Expand All @@ -10,9 +13,16 @@ class PlayFabAuthenticationApi
/// </summary>
public static function GetEntityToken($titleId, $entityToken, $clientSessionTicket, $developerSecreteKey, $request)
{
if (!is_null($entityToken)) { $authKey = "X-EntityToken"; $authValue = $entityToken; }
elseif (!is_null($clientSessionTicket)) { $authKey = "X-Authorization"; $authValue = $clientSessionTicket; }
elseif (!is_null($developerSecreteKey)) { $authKey = "X-SecretKey"; $authValue = $developerSecreteKey; }
if (!is_null($entityToken)) {
$authKey = "X-EntityToken";
$authValue = $entityToken;
} elseif (!is_null($clientSessionTicket)) {
$authKey = "X-Authorization";
$authValue = $clientSessionTicket;
} elseif (!is_null($developerSecreteKey)) {
$authKey = "X-SecretKey";
$authValue = $developerSecreteKey;
}

$result = PlayFabHttp::MakeCurlApiCall($titleId, "/Authentication/GetEntityToken", $request, $authKey, $authValue);
return $result;
Expand Down Expand Up @@ -70,4 +80,5 @@ public static function ValidateEntityToken($titleId, $entityToken, $request)
}

}

?>
4 changes: 4 additions & 0 deletions PlayFabSDK/PlayFabClientApi.php → src/PlayFabClientApi.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

namespace PlayFabSDK;

include 'PlayFabHttp.php';

class PlayFabClientApi
Expand Down Expand Up @@ -2099,4 +2102,5 @@ public static function WriteTitleEvent($titleId, $clientSessionTicket, $request)
}

}

?>
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
namespace PlayFabSDK;

include 'PlayFabHttp.php';

class PlayFabCloudScriptApi
Expand Down Expand Up @@ -150,4 +152,5 @@ public static function UnregisterFunction($titleId, $entityToken, $request)
}

}

?>
3 changes: 3 additions & 0 deletions PlayFabSDK/PlayFabDataApi.php → src/PlayFabDataApi.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
namespace PlayFabSDK;

include 'PlayFabHttp.php';

class PlayFabDataApi
Expand Down Expand Up @@ -88,4 +90,5 @@ public static function SetObjects($titleId, $entityToken, $request)
}

}

?>
3 changes: 3 additions & 0 deletions PlayFabSDK/PlayFabEventsApi.php → src/PlayFabEventsApi.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
namespace PlayFabSDK;

include 'PlayFabHttp.php';

class PlayFabEventsApi
Expand Down Expand Up @@ -29,4 +31,5 @@ public static function WriteTelemetryEvents($titleId, $entityToken, $request)
}

}

?>
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
namespace PlayFabSDK;

include 'PlayFabHttp.php';

class PlayFabExperimentationApi
Expand Down Expand Up @@ -160,4 +162,5 @@ public static function UpdateExperiment($titleId, $entityToken, $request)
}

}

?>
3 changes: 3 additions & 0 deletions PlayFabSDK/PlayFabGroupsApi.php → src/PlayFabGroupsApi.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
namespace PlayFabSDK;

include 'PlayFabHttp.php';

class PlayFabGroupsApi
Expand Down Expand Up @@ -304,4 +306,5 @@ public static function UpdateRole($titleId, $entityToken, $request)
}

}

?>
105 changes: 49 additions & 56 deletions PlayFabSDK/PlayFabHttp.php → src/PlayFabHttp.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

if (!class_exists("PlayFabSettings")) {
namespace PlayFabSDK;
if (!class_exists("PlayFabSDK\PlayFabSettings")) {
class PlayFabSettings
{
public static $versionString = "PhpSdk-0.0.201014";
Expand All @@ -17,31 +18,23 @@ public static function GetFullUrl($titleId, $apiPath, $getParams)
$titleId = PlayFabSettings::$titleId;

$output = "";
if (!(substr(self::$productionEnvironmentUrl, 0, 4) === "http"))
{
if (isset(self::$verticalName))
{
if (!(substr(self::$productionEnvironmentUrl, 0, 4) === "http")) {
if (isset(self::$verticalName)) {
$output = "https://" . self::$verticalName;
}
else
{
} else {
$output = "https://" . $titleId;
}
}

$output .= self::$productionEnvironmentUrl;
$output .= $apiPath;

$firstParam = True;
foreach($getParams as $key => $value)
{
if($firstParam)
{
foreach ($getParams as $key => $value) {
if ($firstParam) {
$output = $output . "?";
$firstParam = False;
}
else
{
} else {
$output = $output . "&";
}

Expand Down Expand Up @@ -87,54 +80,54 @@ public static function MakeCurlApiCall($titleId, $apiPath, $request, $authKey, $
}
curl_setopt($ch, CURLOPT_HTTPHEADER, $httpHeaders);
$rawResult = curl_exec($ch);

if ($rawResult === false)
echo "cUrl Error: " . curl_error($ch) . "\n\n";

curl_close($ch);


return $rawResult;
}

// public static function MakeHttpRequestApiCall($titleId, $apiPath, $request, $authKey, $authValue)
// {
// $fullUrl = PlayFabSettings::GetFullUrl($titleId, $apiPath, PlayFabSettings::$requestGetParams);
// $httpRequest = new HttpRequest($fullUrl, HttpRequest::METH_POST);
// $requestJson = json_encode($request);

// // ApiCall Headers
// $httpHeaders = [
// "Content-Type" => "application/json",
// "X-ReportErrorAsSuccess" => "true",
// "X-PlayFabSDK" => PlayFabSettings::$versionString
// ];
// if ($authKey && $authValue)
// $httpHeaders[$authKey] = $authValue;

// // Compression
// if (PlayFabSettings::$enableCompression) {
// $httpHeaders[$authKey] = $authValue;
// $httpHeaders["Content-Encoding"] = "GZIP";
// $httpHeaders["Accept-Encoding"] = "GZIP";
// $requestJson = gzcompress($requestJson);
// }

// // Perform the call
// $httpRequest->addHeaders($httpHeaders);

// try {
// $httpMessage = $httpRequest->send();
// $responseHeaders = $httpMessage->getHeaders();
// $responseJson = $httpMessage->getBody();

// $responseEncoding = $responseHeaders["Content-Encoding"];
// if (isset($responseEncoding) && $responseEncoding === "GZIP")
// $responseJson = gzdecode($responseJson);
// return $responseJson;
// } catch (HttpException $ex) {
// return $ex;
// }
// $fullUrl = PlayFabSettings::GetFullUrl($titleId, $apiPath, PlayFabSettings::$requestGetParams);
// $httpRequest = new HttpRequest($fullUrl, HttpRequest::METH_POST);
// $requestJson = json_encode($request);

// // ApiCall Headers
// $httpHeaders = [
// "Content-Type" => "application/json",
// "X-ReportErrorAsSuccess" => "true",
// "X-PlayFabSDK" => PlayFabSettings::$versionString
// ];
// if ($authKey && $authValue)
// $httpHeaders[$authKey] = $authValue;

// // Compression
// if (PlayFabSettings::$enableCompression) {
// $httpHeaders[$authKey] = $authValue;
// $httpHeaders["Content-Encoding"] = "GZIP";
// $httpHeaders["Accept-Encoding"] = "GZIP";
// $requestJson = gzcompress($requestJson);
// }

// // Perform the call
// $httpRequest->addHeaders($httpHeaders);

// try {
// $httpMessage = $httpRequest->send();
// $responseHeaders = $httpMessage->getHeaders();
// $responseJson = $httpMessage->getBody();

// $responseEncoding = $responseHeaders["Content-Encoding"];
// if (isset($responseEncoding) && $responseEncoding === "GZIP")
// $responseJson = gzdecode($responseJson);
// return $responseJson;
// } catch (HttpException $ex) {
// return $ex;
// }
// }
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
namespace PlayFabSDK;

include 'PlayFabHttp.php';

class PlayFabInsightsApi
Expand Down Expand Up @@ -78,4 +80,5 @@ public static function SetStorageRetention($titleId, $entityToken, $request)
}

}

?>
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
namespace PlayFabSDK;

include 'PlayFabHttp.php';

class PlayFabLocalizationApi
Expand All @@ -16,4 +18,5 @@ public static function GetLanguageList($titleId, $entityToken, $request)
}

}

?>
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
namespace PlayFabSDK;

include 'PlayFabHttp.php';

class PlayFabMatchmakerApi
Expand Down Expand Up @@ -65,4 +67,5 @@ public static function UserInfo($titleId, $developerSecreteKey, $request)
}

}

?>
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
namespace PlayFabSDK;

include 'PlayFabHttp.php';

class PlayFabMultiplayerApi
Expand Down Expand Up @@ -682,4 +684,5 @@ public static function UploadCertificate($titleId, $entityToken, $request)
}

}

?>
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
namespace PlayFabSDK;

include 'PlayFabHttp.php';

class PlayFabProfilesApi
Expand Down Expand Up @@ -89,4 +91,5 @@ public static function SetProfilePolicy($titleId, $entityToken, $request)
}

}

?>
Loading

0 comments on commit 84d9eeb

Please sign in to comment.