Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/366.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何将Google应用程序端点与phonegap应用程序集成_Javascript_Google App Engine_Cordova - Fatal编程技术网

Javascript 如何将Google应用程序端点与phonegap应用程序集成

Javascript 如何将Google应用程序端点与phonegap应用程序集成,javascript,google-app-engine,cordova,Javascript,Google App Engine,Cordova,我一直在开发Phonegap客户端应用程序,并使用google端点创建所有web服务 但是我在使用api时遇到了问题。在我的index.html中,我有这个脚本 <head><script> var myapi; function initGoogleApis() { var ROOT = "https://myapitest.appspot.com/_ah/api"; gapi.client.load("myapitest

我一直在开发Phonegap客户端应用程序,并使用google端点创建所有web服务

但是我在使用api时遇到了问题。在我的index.html中,我有这个脚本

<head><script>
    var myapi;
    function initGoogleApis() {
        var ROOT = "https://myapitest.appspot.com/_ah/api";
        gapi.client.load("myapitest", "v1", function() {
            myapi = gapi.client.ratemyday;
        }, ROOT); 
    }
</script></head>
<script src="https://apis.google.com/js/client.js?onload=initGoogleApis"></script>
问题是我没有工作,我不知道myapi是未知的 我做错了什么?
我如何使用phonegap使用我的enpoints api?它看起来确实像一个范围变量问题。但我不是100%确定。也许我会检查一下,然后让你知道

而不是做

myapi.items.insert
()

使用

我很确定这应该行得通。在我们的应用程序中,我们使用几乎相同的方式使用50多个端点api调用

我解决了这个问题

这是一个范围变量问题,此外,必须在init函数中调用phonegap onDeviceReady函数

这是我的工作:

     <head><script>
        function initGoogleApis() {
            var ROOT = "https://myapitest.appspot.com/_ah/api";
            gapi.client.load("myapitest", "v1", function() {

            document.addEventListener("deviceready", onDeviceReady, false);

            }, ROOT); 
        }
    </script></head>

<script src="https://apis.google.com/js/client.js?onload=initGoogleApis"></script>

函数initGoogleApis(){
变量根=”https://myapitest.appspot.com/_ah/api";
load(“myapitest”,“v1”,function(){
文件。添加的监听器(“deviceready”,OnDeviceraddy,false);
},根);
}
gapi.client.ratemyday.items.insert()
     <head><script>
        function initGoogleApis() {
            var ROOT = "https://myapitest.appspot.com/_ah/api";
            gapi.client.load("myapitest", "v1", function() {

            document.addEventListener("deviceready", onDeviceReady, false);

            }, ROOT); 
        }
    </script></head>

<script src="https://apis.google.com/js/client.js?onload=initGoogleApis"></script>