简体   繁体   English

使用PHP运行时设置Google Cloud Datastore

[英]Set up Google Cloud Datastore with PHP runtime

I am developing the backend for an app using App Engine with PHP runtime and Google Cloud Datastore. 我正在使用带有PHP运行时和Google Cloud Datastore的App Engine开发应用程序的后端。
I have set up a local development for App Engine and I am using the gcd tool for local Datastore. 我已经为App Engine进行了本地开发,并且正在将gcd工具用于本地数据存储区。
When I send requests to online Datastore it works. 当我向在线数据存储发送请求时,它可以工作。
Unfortunately, when I'm sending any request to local Datastore I get the following error in the browser: 不幸的是,当我向本地数据存储区发送任何请求时,在浏览器中出现以下错误:

Fatal error: Uncaught exception 'Google_Service_Exception' with message 'Error calling
POST http://localhost:8081/datastore/v1beta2/datasets/project-id/allocateIds: (400)
unsupported content-type: application/json; charset=UTF-8' in G:\Programs\Google\Cloud 
SDK\project-id\default\Google\Http\REST.php:79 Stack trace: #0 G:\Programs\Google\Cloud   
SDK\project-id\default\Google\Http\REST.php(44): Google_Http_REST::decodeHttpResponse(
Object(Google_Http_Request)) #1 G:\Programs\Google\Cloud SDK\project-id\default\Google
\Client.php(503): Google_Http_REST::execute(Object(Google_Client), Object(Google_Http_
Request)) #2 G:\Programs\Google\Cloud SDK\project-id\default\Google\Service\Resource.
php(195): Google_Client->execute(Object(Google_Http_Request)) #3 G:\Programs\Google\
Cloud SDK\project-id\default\Google\Service\Datastore.php(153): Google_Service_
Resource->call('allocateIds', Array, 'Google_Service_...') #4 G:\Programs\Google\Cloud 
SDK\project-id\default\DatastoreService.php in G:\Programs\Google\Cloud SDK\
project-id\default\Google\Http\REST.php on line 79

and in the gcd I get the following error: 并在gcd中出现以下错误:

Sep 17, 2014 8:24:07 PM com.google.apphosting.client.serviceapp.BaseApiServlet doPost
INFO: ApiServlet POST
Sep 17, 2014 8:24:07 PM com.google.apphosting.client.serviceapp.BaseApiServlet doCall
INFO: unsupported content-type: application/json; charset=UTF-8
Sep 17, 2014 8:24:07 PM com.google.apphosting.client.serviceapp.BaseApiServlet 
writeErrorResponse
SEVERE: INVALID_ARGUMENT: unsupported content-type: application/json; charset=UTF-8

I have tried changing content-type in Google/Service/Resource.php line 171 but nothing seems to work. 我曾尝试在Google / Service / Resource.php第171行中更改content-type,但似乎无济于事。
Any idea on how can I fix this? 关于如何解决此问题的任何想法?

Unfortunately, Google Cloud Datastore's local development server ( gcd.sh ) does not currently support JSON as a transport (which is used by the PHP client library). 不幸的是,Google Cloud Datastore的本地开发服务器( gcd.sh )当前不支持JSON作为传输(PHP客户端库使用该传输)。

A workaround is to create a second project you use only for testing. 一种解决方法是创建仅用于测试的第二个项目。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM