2012-04-20 2 views
0

GAE를 백엔드 서버 (Java)로 사용하는 모바일 앱 (html5/javascript + PhoneGap)을 제작하고 있습니다. 며칠 후 연구는 여전히 전체 그림을 얻을 수 없었습니다.모바일 앱 (html5/javascript)이 Google App Engine 예제와 통신합니다.

통신 부분에 이러한 구성의 오픈 소스 예가 있습니까? 주로 OAuth는 모바일 클라이언트, 사용자 채널 API, 푸시 알림 등에서 데이터를 보내고받습니다.

GAE의 모든 예제는 웹 앱용이지만 외부 모바일 클라이언트 용은 아닙니다. 그것이 다른 이유입니다.

XMLHttpRequest는 도메인 간 통신을 지원하지 않기 때문에 사용해서는 안됩니다.

내 요구 사항에 jQuery.ajax()가 작동하는 것 같습니다. 다시 말하지만, 오픈 소스 예제 프로젝트는 많은 도움이 될 것입니다!

모든 링크/의견을 보내 주시면 감사하겠습니다.

감사합니다.

+0

모바일 클라이언트가 HTML5와 자바 스크립트의 경우, 그것은 웹 애플리케이션을 _is_. 기존 사례가 부족한 점은 무엇입니까? –

+0

샘플은 webapp가 GAE와 동일한 도메인에 있다고 가정합니다. 모바일 앱이 아닌 경우. –

+0

앱 엔진에서 저지와 같은 안정적인 프레임 워크를 설정할 수 있습니다. – aglassman

답변

0

통신 부분에 이러한 구성의 오픈 소스 예제가 있습니까?

https://github.com/blueimp/jQuery-File-Upload

또는

, 더 JQuery와 아약스 호출을 조사 ...

function uploadPicture() { 

    // blog.w3villa.com/websites/uploading-filesimage-with-ajax-jquery-without-submitting-a-form/ 
    // 

    var form_data = new FormData();  // Creating object of FormData class 
    var file_data = photo.src; // Getting the properties of file from file field 
    // form_data.append("file", file_data); // Appending parameter named file with properties of file_field to form_data 
    // var blob = new Blob([file_data], {type: 'image/png'}); 
    // form_data.append("file", blob) 

    var dataURI = photo.src; 

    alert(dataURI); 

    form_data.append("file", dataURItoBlob(dataURI)); 

    form_data.append("field1", "stuff1");  // Adding extra parameters to form_data 
    alert(JSON.stringify(form_data)); 

    $.ajax({ 
     url: serverURL, 
     dataType: 'json', // the format of the response 
     cache: false, 
     contentType: false, // the format of data being sent to the server as part of request 
     //      shazwazza.com/post/Uploading-files-and-JSON-data-in-the-same-request-with-Angular-JS 
     //      setting the Content-type to 'false' will force the request to automatically 
     //      populate the headers properly including the boundary parameter. 
     // stackoverflow.com/questions/2845459/jquery-how-to-make-post-use-contenttype-application-json 
     // contentType:"application/json; charset=utf-8", 
     // contentType:"multipart/form-data; charset=utf-8", 
     processData: false, // do not convert outgoing data to a string 
     data: form_data,  // Setting the data attribute of ajax with file_data 
     type: 'post', 
     success: function(data) { 
       alert("success! data: " + JSON.stringify(data)); 
       } 
    }); 
+0

감사합니다! 하지만 어떻게 삽입 할 수 있었습니까 ? 나는 그렇게 할 수 없었다. – user1405141

+0

편집이 의미가 있으며 앞으로 어떻게 할 것인지를 알고 있다고 생각합니다. 편집을 "수락"하기 위해해야 ​​할 일이 있습니까? – user1405141