-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use parse-server with the PHP SDK ? #124
Comments
This is without testing (as I haven't started migration testing yet), but I would imagine that it follows a similar line to the other platforms which would be to change the following in the ParseClient.php to point your server.
|
@MarkCYoung Thanks for your answer. That's what I did until now. I also set up the different keys on my parse-server but also in my PHP configuration file... And I always get the message "unauthorized" on all of my requests. Still trying to fix that, but I'm opened to your suggestions! EDIT : My bad, forgot to restart my Parse server after setting the new keys. Now, I'm getting a new error " |
This is due to the default route for the parse-server residing on '/parse' where the Parse PHP SDK utilises '/1'. Refer to this line in ParseClient.php:24
Or modify your ParseClient.php to use '/parse'. I assume this will be fixed in the next release of the SDK. |
I need to update the PHP SDK with a method for changing the server URL... I missed it. |
@fraxool would you be willing to share your source code on how you got your swift code connected to your parse server? |
Waiting for method to change server URL ... thanks ! |
Sorry for the late guys. I wrote a complete answer on StackOverflow to fix that : |
@gfosco any updates to the php sdk you can push please? |
So I did the sort of hack today and changed some values in ParseClient.php
and
My app key, rest key and master key all match up whats on the server, and I'm able to do a CURL request to get the data im trying to in php, but every time I try it in php it returns "unauthorized" I have checked my keys and restarted my parse server to make sure nothing silly was happening and since the CURL request worked I'm not sure what to do next.. any ideas? Heroku log
any ideas? |
Anyone have any ideas.. im pretty stuck from moving forward from my comment above ^^^ |
that hack enabled me to read values from my parse-server, but the save() function doesn't seem to work in the current php sdk... |
@occurrentarts what did you change to make this work.. I'm currently stuck on the php side of things :( |
finally i have object saving and image and audio uploads working with the PHP SDK. |
Updated push handling for local or non-local time push.
I updated the PHP SDK to version 1.2.0, you can now change the server URL after initialization:
|
thanks @gfosco |
@occurrentarts fileKey should only be required on the parse-server side, for legacy files hosted by Parse. |
@gfosco thanks for the update.. I'm getting an unauthorized response when doing a query. Here is simple php script..
Heroku logs..
My keys from index.js thats running on my parser server
I dont care about the keys being posted here, these are just temp but I wanted to display that they match the php ones.. Printing out the url from the ParseClient gives me this..
returned value: unauthorized. Either im missing something simple or something is broke. @gfosco any thoughts on how I could help debug this further.. ? EDIT: I should mention JS and CURL requests work. |
According to that code, you're passing |
@gfosco ok this is a bit confusing since ill need the js key for my js code, php for rest api, and master.. also our app will be using the client key.. So ideally I need these keys unless Im missing something. making the change for index.js to
Gave me the same results. Disabling clientKey and javascriptKey and clientKey in index.js solved the problem. However this begs the question then on the JS side of things you have to embed your master key which could bee seen in source code if your doing front end stuff, isnt this a security issue? See concern at #352 ` <script type="text/javascript">
btw thank you for taking the time with this. |
You don't embed the master key anywhere. It's just that with parse-server, you don't need client keys, the app id is sufficient identification. They don't add any extra security on parse-server, since they are provided together in visible client code. |
You say not to set any of the client keys, I assume your saying in the app.js file for parse-server. But in the the Parse Server Guide the SDK Usage says to initialize PHP with the following.
All of the other SDKs just say to use the APP_ID. Im having a heck of a time getting all these Keys and SDK's and CloudCode to work right. I applaud the community for everyone supporting each other thou. |
@petek157 did you ever find a solution to this? I'm still stuck on the PHP SDK giving me an unauthorized error. |
Well.... I did get it working, but its been so long that I really dont remember what was going on then or what I did to fix it. If you dont have a CLIENT KEY in your app file, try putting a random string in your ParseClient::initialize call for the YOUR_CLIENT_KEY. I know once apon a time that was something that I did that fix a problem. Ha whether it was this one or not I really cant remember. |
Thanks for the reply @petek157. I'm using AWS' Elastic Beanstalk implementation and it doesn't include a client/api key. So I have a random string in my ParseClient::initialize call now, but it's still giving that unauthorized error. Struggling to find any resolution outside of potentially this being the issue... parse-community/parse-php-sdk#225 Not really sure how to resolve this. |
This works for me.. here is a snippet of code I'm using in our framework.
make sure when doing queries you have $useMasterKey = true set in a ->find or what ever the end query is.. |
@gateway that was my issue! Thank you so much for the help there. Do you know if there's a way to do a ->get('ID') or do you have to use ->find() and limit it to 1 result? |
any sort of ->first($useMasterKey = true) etc, use the master key inside.. so if you only want one record use first, otherwise find etc.. |
Hello!
I have a Parse server running and working well with my Swift code. Now, I would like to connect this MongoDB server to my PHP code. But I can't find any documentation on how to do that.
For the moment, I have this code :
ParseClient::initialize( $app_id, $rest_key, $master_key );
How to update it to add my server URL ?
Thanks!
Axel
The text was updated successfully, but these errors were encountered: