"2016.01.18" interface agent via fiddler tool-run with local interface agent on-line interface

Source: Internet
Author: User
Tags app service

Fiddler is one of the tools for crawling requests, similar to Charles and so on, you should close other agent tools before using Fidder

The requirements are as follows:

Web site front-end and server-side development of a page, will be transferred to interface A's data and presented on the page, now because the business requirements need to develop a new interface B, in the original front-end logic under normal display. So, in the process of development, in the absence of front-end coordination, how does the server make this page to the interface of B and render it?

The solution is this:

take a product of where to go for example: Http://szgq1.package.qunar.com/user/id=187688454&abt=a#tf=tejiaqunar

Open the link with Chrome, open the Developer tool, and select NETWORK-XHR to see the list of interfaces on the service side of the page call

(On the right is the interface called by the page)

Take the Getbottomrecommend interface as an example,

Right-clicking the interface address and opening it in a new page will show the interface's entry and exit parameters.

interface Request:http://szgq1.package.qunar.com/user/recommend/getBottomRecommend.json?pId=187688454

Entry is product id:pid=187688454

The out parameter is the list array of recommended products:

The output of the parameter appears as shown:

Suppose, we have developed a new product recommendation interface, the interface address is User/recommend/newgetbottomrecommend.json

Before modifying the interface address in front of the website (sometimes, the situation is more complicated, we are developing the app service side, providing an interface to a page of the app, before the app modifies the interface address and packs it to us, we can only visualize the effect of the display by observing the structure of the data. In general, the PC or M station has such a page for us to test the use of, we developed in the original interface need to display the new interface returned data

Open the Fiddler software, refresh the Product Details page just now, and in the Fiddler window, all requests will be crawled.

The A area shows all the requests that the page initiated after the refresh, where we find the request we want to modify

1. In the right area, select Autoresponder Add Agent

2. Tick these three items

3. Add rule adds Agent

4, enter the original interface address in 4 http://szgq1.package.qunar.com/user/recommend/getBottomRecommend.json?pId=187688454

5, enter the interface address of the agent in 5, we first choose the 404_plain.dat to try, theoretically call this interface will report 404 error (Cannot find file)

6, save operation, refresh interface request found interface return value is

At this point, the product recommendation module in the page shows the result:

Visible, at this time, the module corresponding to the line interface tune is our agent 404 of the New interface.

7, we can also use the JSON file to replace the interface request, for example, we will copy the original JSON file, to modify

{"ret": True, "data": {"group": [{"Min_price": 0, "Count": 1024x768, "Short_arr": "My Home +", "arr": "Japan, Osaka, Kyoto", "Departure": "Blog Park", "Takeoff_date": "Today", "url": "/search/group-a-a-%e4%b8%8a%e6%b5%b7-----%e6%97%a5%e6%9c%ac-4812----20160127-10758" }]}}

Save As Newreturn.json and select this file in the location requested by the new interface

At this point, the request result of the interface is what we entered:

The results of the page display are:

Hope to help you.

"2016.01.18" interface agent via fiddler tool-run with local interface agent on-line interface

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.