本人从事海外游戏制作和发行,参与了不少海外研发团队studio的项目,这里我将个人接触到的一些使用Playfab开发的项目心得分享给大家。
PlayFab简介
playfab是一家主要为游戏开发人员提供游戏开发和管理的跨平台工具及服务的公司,
PlayFab正在构建当今游戏所需的所有基于云的基础架构:玩家匹配,排行榜,服务器托管,玩家身份/个人资料管理,第三方登录和支付SDK支持,商务等等。PlayFab的目的是让游戏开发人员专注于他们的游戏,为他们处理服务器端的工作。PlayFab的服务与平台无关,微软保留了这方面的内容:有适用于Xbox,Windows,PlayStation,Switch,iOS和Android的SDK,这对于一些开发者来说降低了开发的门槛。
同时PlayFab后台为运营支撑的同事提供了比较丰富的玩家数据分析统计表格,很直观的看到玩家的新增,付费,转化率等关键信息。
因此PlayFab可以满足绝大多数游戏开发制作团队的需要,只需要几个美术,客户端,策划在后台配置一些关键的匹配,排行,商品货币等信息,就可以快速做一个游戏,这个要得益于PlayFab为Playfab为开发者提供了丰富的接口。
PlayFab丰富的API接口
可以参考 REST API 参考 - PlayFab | Microsoft Learn
如图:
编辑
在这里,我们可以根据自己需要来选择不同的API和方法来实现自己的服务器端逻辑或者测试接口,对于playfab都提供了哪些接口可以参考https://api.playfab.com/documentation 这里有很多API,这里比如我想写一个加虚拟货币的。
- AddUserVirtualCurrency
POST https://{{TitleID}}.playfabapi.com/Server/AddUserVirtualCurrency Content-Type: application/json X-SecretKey: <developer_secret_key> { "PlayFabId": "20394883", "VirtualCurrency": "GC", "Amount": 100 }
- 对应的链接是 https://api.playfab.com/documentation/server/method/AddUserVirtualCurrency 这里有一个TRY IT 你可以点击自定义参数,其中PlayFabId是你需要增加虚拟币的玩家id,VirtualCurrency是你在后台配置的货币单位,Amount是个数。
- 编辑
- 当然我可以自己利用官网的SDK自己写逻辑,
SDK可以从Azure PlayFab 文档 - PlayFab | Microsoft Learn来下载。
比如我使用的是PHP开发,那么使用 https://docs.microsoft.com/zh-cn/gaming/playfab/sdks/php/ 下载后可以根据尝试编写一个测试用例 AddUserVirtualCurrency.php 放在ExampleProject目录下:
<?php include "../PlayFabSDK/PlayFabClientApi.php"; include "../PlayFabSDK/PlayFabServerApi.php"; include "../PlayFabSDK/PlayFabMatchmakerApi.php"; include "../PlayFabSDK/PlayFabAdminApi.php"; try { $TitleId = "XXXX";//This should just be hard coded into your server $PlayFabApi = "Server"; $ApiMethod = "AddUserVirtualCurrency"; $DevSecretKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";// This should just be hard coded into your server $jsonData = array("Amount"=>100, "PlayFabId"=>"E8EBDB378AEDAB4A", "VirtualCurrency"=>"GC"); $JsonRequest = $jsonData; var_dump($JsonRequest); $authValue = $DevSecretKey; $apiReflection = new ReflectionClass("PlayFab" . $PlayFabApi . "Api"); $methodReflection = $apiReflection->getMethod($ApiMethod); $result = $methodReflection->invoke(null, $TitleId, $authValue, $JsonRequest); echo $result; } catch (Exception $e) { echo "Caught exception: ", $e->getMessage(), "\n"; } ?>
- 运行php文件得到结果:
- 编辑