Results 1 to 4 of 4

Thread: https post from zimlets

  1. #1
    Join Date
    Dec 2009
    Posts
    4
    Rep Power
    5

    Default https post from zimlets

    Hi,
    I'm writting a Zimlets which need to send a http request to a php application. I have written this source code :
    PHP Code:
    var url "https://app.132.com/my.php";

    var 
    params "to=" smsParams.to "&msg=" smsParams.body;

    var 
    reqParam AjxStringUtil.urlEncode(params);
    var 
    reqHeader = {"Content-Type":"application/x-www-form-urlencoded"};

    AjxRpc.invoke(reqParamurlreqHeader, new AjxCallback(thisthis._resultCallback)); 
    The PHP code do not receive any parameters.
    Is it the right way to do? Is there a way to specify GET or POSt http method?
    Thanks

  2. #2
    Join Date
    Nov 2009
    Posts
    105
    Rep Power
    6

    Default

    There is a parameter after the callback on AjxRpc.invoke that specifies "useGET" true/false.

    Send via GET:

    Code:
    var url = "http://www.theurliwanttocall.com";
    var response = AjxRpc.invoke(requestData, url, headers, callback, true);
    Send via POST:

    Code:
    var url = "http://www.theurliwanttocall.com";
    var response = AjxRpc.invoke(requestData, url, headers, callback, false);
    Last edited by sposetti; 02-24-2010 at 01:17 PM.

  3. #3
    Join Date
    Nov 2009
    Posts
    105
    Rep Power
    6

    Default

    One thing to note: calling an external server from zimlet JavaScript is not allowed. This is a cross-domain scripting security limitation imposed by browsers. You can't call from a browser using JavaScript to a server other than the originating server.

    However, you can use the Proxy Servlet to get around this security limitation.

    1) Call AjxRpc and the URL is the proxy servlet
    2) Pass a param for target that is the url + request of the server you want to proxy to.
    3) The proxy servlet will take your request, proxy to the external server and send you back the response.

    More info on configuring, testing and using the Proxy Servlet can be found here:

    ZCS 6.0:Zimlet Developers Guide:Proxy Servlet Setup - Zimbra :: Wiki

  4. #4
    Join Date
    Nov 2009
    Posts
    105
    Rep Power
    6

    Default

    Also added an example that shows calling the Proxy Servlet from a zimlet:

    ZCS 6.0:Zimlet Developers Guide:Examples:HTTP GET and POST - Zimbra :: Wiki

Similar Threads

  1. Unable to access Yahoo account via Zimbra Desktop
    By drdrem in forum Error Reports
    Replies: 10
    Last Post: 10-13-2009, 02:30 PM
  2. ZCS 6 not allowing POST to Zimlet's jsp?
    By chlauber in forum Developers
    Replies: 1
    Last Post: 09-15-2009, 11:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •