I will share with you an even-write tutorial ___ question about using the Google Mini-tool API to request a self-use Server

Source: Internet
Author: User
In the igoogle tool, you can do some very simple or complex applications. Most of the applications are done locally using JavaScript and XML. They only reference a remote data source, then we use Google's API to parse the content and present it in a special way. Google's API is indeed powerful, although it provides a little less functionality than the general JavaScript library, however, these features are the essence of the essence, providing many advanced features that can be used to make a lot of interesting applications, such as using the grid library for some of your most common games, tetris? Greedy? Push box? Don't think that games won't become popular. Many people who use igoogle are technicians who will write Program Methods are of interest, and ordinary people will also recall their childhood scenes.

Now, you can use local APIs to do a lot of things, but it seems a little too simple to be confined to these things. gadgets can also carry large applications, have you ever thought that twiter will become an application with traffic and Google side by side? It seems very mentally retarded, but it is popular because it conforms to the user's fast-paced life, that is to say, you can make big applications in gadgets. To achieve this, you must first make the gadgets communicate with third-party servers and interact with CGI programs and databases on the servers.

I actually want to talk about the problems I encountered when using the map API. There is a namespace in the Google map API called Gxmlhttp is used to perform Asynchronous interaction with the server (Ajax). If you embed a map in a widget, you will first think of this namespace. Html In fact, this namespace cannot work when hosted on Google's gadgets server, because it involves the issue of Using ajax to request third-party domains, which is a security issue, most browsers do not allow such requests. Because many uncertain security factors are hidden, you cannot use this namespace to request data and programs on your server when embedding a map in a widget.

Since there is a problem, there are two solutions:

1. the first one is the easiest way to think of. You can directly reference the HTML file on your server as a URL. At this time, your HTML page is placed on your server. If it sends a request, the request is also sent to the server where it is located, so there is no such problem,

2. however, if you want to save your server from the difficulty of HTML file access, there is also a second solution, that is, Google managed its own mini-tool files in HTML mode, and used the _ ig_fetchcontent () provided by the mini-tool to enable GoogleMap to interact with the server () and a series of similar functions (please refer to the API documentation). The specific method is not explained in detail, but I think this method is not as good as directly using mapapi.

At this point, many people will ask: why are functions in the map API unavailable, but functions in the mini-tool API can be used? This is because Google can access the third-party domain through some special methods in the mini-tool API. I guess it is implemented using the proxy server method, that is, when you request your own server, in fact, your request is not a direct request to your own server, but to the Google server, google's server uses scripts to request your server again. I don't remember the details. in PHP, there seems to be a function called file_get_content (), which is used to request a third-party server, your request is redirected to your server and then to your gadgets, it is a good choice to use functions provided by mapapi for request speed and performance.

The above question is also why the _ ig_fetchcontent () function is not allowed in HTML files referenced by URL, because when you request your server, in fact, the request is a third-party Google proxy server, so it is not allowed. For details, please refer to the manual. This issue is quite important.

I have a limited level and a limited literary talent. If I don't know how to add QQ: 676588498, I can discuss it together. I am also participating in this competition.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.