question

Fabio Cassio de Carvalho avatar image
Fabio Cassio de Carvalho asked

PHP example for Client Connection not Working

So, I was developing for Unity but at some point I needed to change to PHP for alternative requests.

I've downloaded the PHP Playfab SDK from github, added the ExampleProject to my localhost directory, looked for the documentation to make the right requisition, but the Client custom Login was not working.

I tried to fill the blanks as the documentation said, using the correct apache and PHP version, SSL from the link in the documentation, yet I always get the following error:

<br />
<b>Warning</b>:  Creating default object from empty value in <b>C:\xampp\htdocs\PlayFabSDK\PlayFabClientApi.php</b> on line <b>1139</b><br />
{ "code":400, "status":"BadRequest", "error":"InvalidParams", "errorCode":1000, "errorMessage":"Invalid input parameters", "errorDetails":{  "":[   "One of the following properties must be defined: CustomId, EncryptedRequest"    ]  }}

Tried to Hardcode some values, but with no success.

Also, tried to make some Server requisiton just so I would check if other functions were working, like GetTime, and it worked without any problem:

{"code":200,"status":"OK","data":{"Time":"2020-05-15T23:36:17.246Z"}}

Do you guys have any idea what it could be? I need to make Client requests.

Thanks for the attention

apissdksAuthentication
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sarah Zhang avatar image
Sarah Zhang answered

It's a known issue about PHP SDK code, please refer to this thread -- https://community.playfab.com/questions/36134/php-sdk-not-working.html to modify the ExampleProject\ajaxPlayFabApi.php.

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Ilse Mul avatar image Ilse Mul commented ·

I just ran into the same problem. Maybe the Quickstart Guide and the SDK can be updated with this?

I'm asking here since I suggested an edit to the Quickstart guide on Github about the link to the CA-bundle becoming deprecated and was referred back to the forums since I'd probable get more help here.....

0 Likes 0 ·
Mackenzie Power avatar image
Mackenzie Power answered

@Ilse Mul Hey did you get it working? We're actually doing something very similar to you as we are developing in Unity but require a web front end for our software.
We did a LOT of digging before we were able to get the problem solved.

1.) We installed XAMPP which comes with Apache and PHP So on that PHP
2.) We downloaded the phpSDK they have and placed it in our xampp/htdocs folder.
3.) We commented out line 19 of ajaxPlayFabApi.php which was:

$result = $methodReflection->invoke(null, $TitleId, $authValue, $JsonRequest);


and then added a new code right after which is:

if($authValue) $result = $methodReflection->invoke(null, $TitleId, $authValue, $JsonRequest);
else $result = $methodReflection->invoke(null, $TitleId, $JsonRequest);


4.) Opened XAMPP, started the Apache module
5.) Navigated on our webrowser to http://localhost/PhpSdk-master/ExampleProject/gui.php and ran the CustomID function.

On the Quickstart page we just completely ignored the CA-bundle stuff since it is deprecated (as you mentioned).
We tried using the "LoginWithEmailAddress" and "RegisterPlayFabUser" and it seems to work now with the code change.

Hopfully this post helps!

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Ilse Mul avatar image Ilse Mul commented ·

Hi @Mackenzie Power


I checked the docs. As it turned out, the Git has one file corrected (PlayFabHttp.php), but the other not yet (ajaxPlayFabApi.php). I made the same adjustments as you did.

I'm running it on a live server, but completely separated from my site, so the CA-bundle that comes with my own SSL is already installed in my installation. I checked that with the host.

I do think the Quickstart guide should be updated, as well as the GitHub source. But somewhere I read the PHP SDK doesn't have priority and thus isn't quite maintained as much as the rest.

I'm setting up custom pages as we speak, for registration, login, etc. Ideally I want to create a complete account management system and combine it with probably MediaWiki for more possibilities and a forum.

Maybe we can help each other in the future. Let's stay in touch :)

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.