CN112351064B - Method for redirecting network request by iOS (Internet operating System) by using AFNetworking - Google Patents

Method for redirecting network request by iOS (Internet operating System) by using AFNetworking Download PDF

Info

Publication number
CN112351064B
CN112351064B CN202010978557.8A CN202010978557A CN112351064B CN 112351064 B CN112351064 B CN 112351064B CN 202010978557 A CN202010978557 A CN 202010978557A CN 112351064 B CN112351064 B CN 112351064B
Authority
CN
China
Prior art keywords
redirection
network request
afnetworking
library
interface
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202010978557.8A
Other languages
Chinese (zh)
Other versions
CN112351064A (en
Inventor
程志恒
许振�
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou Dynamic Internet Technology Co ltd
Original Assignee
Hangzhou Dynamic Internet Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hangzhou Dynamic Internet Technology Co ltd filed Critical Hangzhou Dynamic Internet Technology Co ltd
Priority to CN202010978557.8A priority Critical patent/CN112351064B/en
Publication of CN112351064A publication Critical patent/CN112351064A/en
Application granted granted Critical
Publication of CN112351064B publication Critical patent/CN112351064B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/56Provisioning of proxy services
    • H04L67/563Data redirection of data network streams
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • H04L67/148Migration or transfer of sessions

Abstract

The invention provides a method for redirecting a network request by iOS (Internet operating System) by using AFNetworking, which comprises the following steps: using an iOS terminal to access a network request, and calling a rear-end interface by AFNetworking; the back-end interface redirects and returns back-end data containing the network request code and the redirected interface address; the iOS terminal analyzes the back-end data, extracts the redirection state code, performs subsequent operation according to the redirection state code, and returns to the redirection interface address; and the AFNetworking redirects the network request according to the redirected interface address and re-requests the redirected interface. The method for redirecting the network request by using AFNetworking by the iOS carries out secondary encapsulation and transformation of AFNetworking, so that the problem of network redirection can be solved after the encapsulation is carried out again.

Description

Method for redirecting network request by iOS (Internet operating System) by using AFNetworking
Technical Field
The invention relates to the technical field of redirection, in particular to a method for redirecting a network request by using AFNetworking by iOS.
Background
Currently, AFNetworking is used for carrying out network request in the current iOS native development, but the AFNetworking cannot carry out network request redirection according to the self requirement of a project.
Disclosure of Invention
One of the purposes of the invention is to provide a method for using AFNetworking to redirect network requests by iOS, which performs secondary encapsulation and transformation of AFNetworking so that the network redirection problem can be dealt with after re-encapsulation.
The method for redirecting the network request by using AFNetworking by the iOS provided by the embodiment of the invention comprises the following steps:
using an iOS terminal to access a network request, and calling a rear-end interface by AFNetworking;
the back-end interface redirects and returns back-end data containing the network request code and the redirected interface address;
the iOS terminal analyzes the back-end data, extracts the redirection state code, performs subsequent operation according to the redirection state code, and returns to the redirection interface address;
and the AFNetworking redirects the network request according to the redirected interface address and re-requests the redirected interface.
Preferably, the method for the iOS to redirect the network request by using AFNetworking further includes:
and marking the displayed interface based on the redirection state code when displaying the redirected network data.
Preferably, the labeling the display interface based on the redirection status code includes:
when the redirection state code is temporary redirection, marking the edges around the frame of the display interface in yellow;
when the redirection state code is permanently redirected, marking the edges around the frame of the display interface by adopting red;
and when the redirection state code is used for searching other parts, marking the edges around the frame of the display interface by blue.
Preferably, an iOS end is used for network request access, and AFNetworking calls a rear-end interface; the method comprises the following steps:
analyzing the network request, and acquiring a resource identifier and/or a network address identifier of the network request;
and when the resource identifier and/or the network address identifier comprise a redirection identifier, the AFNetworking calls a back-end interface.
Preferably, the redirecting is performed by the backend interface, and the backend data including the network request code and the redirected interface address is returned, including:
calling first redirection information in a first redirection library stored locally through a rear-end interface, and matching the network request with the first redirection information; and when the matching is matched, acquiring the network request code and the redirected interface address in the first redirection information.
Preferably, the back-end interface performs redirection and returns back-end data including the network request code and the redirected interface address, further comprising:
accessing a second redirection database at the network side through a rear-end interface, acquiring second redirection information of the second redirection database, and matching the network request with the second redirection information; and when the matching is matched, acquiring the network request code and the redirected interface address in the second redirection information.
Preferably, the method for the iOS to redirect the network request by using AFNetworking further includes:
and the second redirection library acquires the network request in the preset area and request result data corresponding to the network request, extracts third redirection information from the request result data, and processes and stores the third redirection information.
Preferably, the method for the iOS to redirect the network request by using AFNetworking further includes:
updating the first redirection library regularly, wherein the updating operation comprises the following steps: and accessing the first redirection library into a second redirection library of the region at regular time, and updating the first redirection library based on the updating table in the second redirection library.
Preferably, the step of generating the updated table in the second redirect library is as follows:
counting second redirection information generated by the second redirection library in a first time period from last access time to last access time of the first redirection library;
acquiring the frequency of the second redirection information in a preset area in a first time period;
extracting corresponding second redirection information with frequency greater than a preset threshold value to generate an update table; and/or arranging the frequency according to the numerical value from large to small, selecting the second redirection information corresponding to the first N bits, and generating an update table.
Additional features and advantages of the invention will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. The objectives and other advantages of the invention will be realized and attained by the structure particularly pointed out in the written description and claims hereof as well as the appended drawings.
The technical solution of the present invention is further described in detail by the accompanying drawings and embodiments.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this specification, illustrate embodiments of the invention and together with the description serve to explain the principles of the invention and not to limit the invention. In the drawings:
fig. 1 is a schematic diagram of a method for an iOS to redirect a network request by using AFNetworking in an embodiment of the present invention.
Detailed Description
The preferred embodiments of the present invention will be described in conjunction with the accompanying drawings, and it will be understood that they are described herein for the purpose of illustration and explanation and not limitation.
The embodiment of the invention provides a method for redirecting a network request by using AFNetworking by iOS, which comprises the following steps as shown in figure 1:
s1, using an iOS end to perform network request access, and using AFNetworking to call a rear-end interface;
s2, the back-end interface redirects and returns back-end data containing the network request code and the redirected interface address;
step S3, the iOS terminal analyzes the back-end data, extracts the redirection state code, carries out subsequent operation according to the redirection state code and returns to the redirection interface address;
and S4, the AFNet redirecting carries out network request redirection according to the redirected interface address, and the redirected interface is requested again.
The working principle and the beneficial effects of the technical scheme are as follows:
when a user uses an iOS end to access a network request, when the network request has a redirected identification, AFNetworking calls a rear-end interface; the back-end interface redirects and returns back-end data containing the network request code and the redirected interface address; the iOS terminal analyzes the back-end data, extracts the redirection state code, performs subsequent operation according to the redirection state code, and returns to the redirection interface address; and the AFNetworking redirects the network request according to the redirected interface address and re-requests the redirected interface. The problem that the network request can not be redirected according to the self requirements of the project by AFNetworking is solved.
In one embodiment, the method for redirecting the network request by the iOS using AFNetworking further includes:
and marking the displayed interface based on the redirection state code when displaying the redirected network data.
Labeling the display interface based on the redirection status code, comprising:
when the redirection state code is temporary redirection, marking the edges around the frame of the display interface in yellow;
when the redirection state code is permanently redirected, marking the edges around the frame of the display interface by adopting red;
and when the redirection state code is used for searching other parts, marking the edges around the frame of the display interface by blue.
The working principle and the beneficial effects of the technical scheme are as follows:
and marking the redirection state when displaying, so that a user can know whether the way of acquiring the network data is redirected or not and the redirection state.
In one embodiment, an iOS terminal is used for network request access, and AFNetworking calls a back-end interface; the method comprises the following steps:
analyzing the network request, and acquiring a resource identifier and/or a network address identifier of the network request;
and when the resource identifier and/or the network address identifier comprise a redirection identifier, the AFNetworking calls a back-end interface.
The working principle and the beneficial effects of the technical scheme are as follows:
when a network request of a user is required, the network request needs to be judged, and when the network request does not need to be redirected, the network request is directly carried out; the judgment method is as follows: analyzing the network request, and acquiring a resource identifier and/or a network address identifier of the network request; and when the resource identifier and/or the network address identifier comprise a redirection identifier, the AFNetworking calls a back-end interface. The identification of the network request can be determined by a pre-stored identification library, that is, the website in the network request is substituted into the identification library for searching, and the identification is determined. The pre-stored identity library is established based on the second redirection library and may be updated periodically in accordance with the second redirection library.
In one embodiment, the redirecting the backend interface and returning the backend data including the network request code and the redirected interface address comprises:
calling first redirection information in a first redirection library stored locally through a rear-end interface, and matching the network request with the first redirection information; and when the matching is matched, acquiring the network request code and the redirected interface address in the first redirection information.
And/or the presence of a gas in the gas,
accessing a second redirection database at the network side through a rear-end interface, acquiring second redirection information of the second redirection database, and matching the network request with the second redirection information; and when the matching is matched, acquiring the network request code and the redirected interface address in the second redirection information.
The working principle and the beneficial effects of the technical scheme are as follows:
the back-end interface redirects and returns back-end data containing the network request code and the redirected interface address, and has two implementation modes: a first redirection library stored with a mobile phone local area determines a network request code and a redirection interface address of a network request by calling and inquiring first redirection information in the first redirection library; the other type is accessed to a second redirection library at the network side through a rear-end interface, second redirection information of the second redirection library is obtained, and the network request is matched with the second redirection information; when the matching is matched, acquiring a network request code and a redirected interface address in the second redirection information; and can also be used comprehensively, and the redirection information is inquired in a local first redirection library and then accessed into a second redirection library for inquiry. The second redirection library at the network side is responsible for division according to the region on the geographical position, and the second redirection library can be ensured to load the determination of redirection in the region; and the second redirection library at the access network side is accessed into the second redirection library corresponding to the area mainly according to the area where the mobile phone is located.
In one embodiment, the method for redirecting the network request by the iOS using AFNetworking further includes:
and the second redirection library acquires the network request in the preset area and request result data corresponding to the network request, extracts third redirection information from the request result data, and processes and stores the third redirection information.
The working principle and the beneficial effects of the technical scheme are as follows:
the preset area is a responsible area divided into a second redirection library by the geographic position; updating redirection information in a second redirection library according to the redirection of the network request occurring in the preset area; an update operation of the second redirect base is implemented.
In one embodiment, the method for redirecting the network request by the iOS using AFNetworking further includes:
updating the first redirection library regularly, wherein the updating operation comprises the following steps: and accessing the first redirection library into a second redirection library of the region at regular time, and updating the first redirection library based on the updating table in the second redirection library.
The update table in the second redirection library is generated as follows:
counting second redirection information generated by the second redirection library in a first time period from last access time to last access time of the first redirection library;
acquiring the frequency of occurrence of second redirection information in a preset area in a first time period;
extracting corresponding second redirection information with frequency greater than a preset threshold value to generate an update table; and/or arranging the frequency according to the numerical value from large to small, selecting the second redirection information corresponding to the first N bits, and generating an update table.
The working principle and the beneficial effects of the technical scheme are as follows:
the first redirection library is used as a pre-processing library of the second redirection library in the local; the first redirection library needs to be updated regularly, and the first redirection library is updated quickly through the update table in the second redirection library. Updating the table by extracting corresponding second redirection information with a frequency greater than a preset threshold; and/or arranging the frequency according to the numerical value from large to small, and selecting second redirection information corresponding to the first N bits; the method and the device realize simple and representative data updating, and enable the updated first redirection library not to be too large, thereby occupying much mobile phone memory.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present invention without departing from the spirit and scope of the invention. Thus, if such modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include such modifications and variations.

Claims (9)

1. A method for using AFNetworking to redirect network requests by iOS is characterized by comprising the following steps:
using an iOS terminal to access a network request, and calling a rear-end interface by AFNetworking;
the back-end interface redirects and returns back-end data containing the network request code and the redirected interface address; acquiring redirection information in a redirection library through a rear-end interface, and matching the network request with the redirection information; when the matching is matched, the network request code and the redirected interface address in the redirection information are obtained; the redirection library comprises a first redirection library and a second redirection library, wherein the first redirection library is locally stored, and the second redirection library is arranged on a network side;
the iOS terminal analyzes the back-end data, extracts a redirection state code, performs subsequent operation according to the redirection state code, and returns to the redirected interface address;
and the AFNetworking redirects the network request according to the redirected interface address and re-requests the redirected interface.
2. The method of iOS network request redirection using AFNetworking according to claim 1, further comprising:
and marking the displayed interface based on the redirection state code when displaying the redirected network data.
3. The iOS method for network request redirection using AFNetworking according to claim 2,
the labeling the display interface based on the redirection status code comprises:
when the redirection state code is temporary redirection, marking the edges around the frame of the display interface in yellow;
when the redirection state code is permanently redirected, marking the edges around the frame of the display interface by adopting red;
and when the redirection state code is used for searching other parts, marking the edges around the frame of the display interface by blue.
4. The iOS method of network request redirection using AFNetworking according to claim 1,
the iOS end is used for carrying out network request access, and AFNetworking calls a rear-end interface; the method comprises the following steps:
analyzing the network request, and acquiring a resource identifier and/or a network address identifier of the network request;
and when the resource identifier and/or the network address identifier comprise a redirection identifier, the AFNetworking calls a back-end interface.
5. The method of iOS redirecting network requests using AFNetworking according to claim 1, wherein the back-end interface redirects and returns back-end data containing a network request code and a redirected interface address, comprising:
calling first redirection information in a first redirection library stored locally through a rear-end interface, and matching the network request with the first redirection information; and when the matching is matched, acquiring the network request code and the redirected interface address in the first redirection information.
6. The method of iOS redirecting network requests using AFNetworking according to claim 1, wherein the back-end interface redirects and returns back-end data containing a network request code and a redirected interface address, further comprising:
accessing a second redirection library at a network side through a back-end interface, acquiring second redirection information of the second redirection library, and matching the network request with the second redirection information; and when the matching is matched, acquiring the network request code and the redirected interface address in the second redirection information.
7. The method of iOS network request redirection using AFNetworking according to claim 5 or 6, further comprising:
and the second redirection library acquires a network request in a preset area and request result data corresponding to the network request, extracts third redirection information from the request result data, and processes and stores the third redirection information.
8. The method of iOS network request redirection using AFNetworking according to claim 7, further comprising:
updating the first redirection library regularly, wherein the updating operation comprises the following steps: and accessing the first redirection library to a second redirection library of the region at regular time, and updating the first redirection library based on an update table in the second redirection library.
9. The method of iOS network request redirection using AFNetworking according to claim 8, wherein the step of generating the update table in the second redirection library is as follows:
counting second redirection information generated by the second redirection library in a first time period from last access time to last access time of the first redirection library;
acquiring the frequency of the second redirection information occurring in the preset area in the first time period;
extracting the corresponding second redirection information with the frequency larger than a preset threshold value to generate the update table; and/or arranging the frequencies from large to small according to numerical values, selecting the second redirection information corresponding to the first N bits, and generating the update table.
CN202010978557.8A 2020-09-17 2020-09-17 Method for redirecting network request by iOS (Internet operating System) by using AFNetworking Active CN112351064B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010978557.8A CN112351064B (en) 2020-09-17 2020-09-17 Method for redirecting network request by iOS (Internet operating System) by using AFNetworking

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010978557.8A CN112351064B (en) 2020-09-17 2020-09-17 Method for redirecting network request by iOS (Internet operating System) by using AFNetworking

Publications (2)

Publication Number Publication Date
CN112351064A CN112351064A (en) 2021-02-09
CN112351064B true CN112351064B (en) 2023-04-07

Family

ID=74358027

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010978557.8A Active CN112351064B (en) 2020-09-17 2020-09-17 Method for redirecting network request by iOS (Internet operating System) by using AFNetworking

Country Status (1)

Country Link
CN (1) CN112351064B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114363417A (en) * 2021-12-13 2022-04-15 南京莱斯信息技术股份有限公司 Optimization design method for service interface concurrent call between systems

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104038510A (en) * 2013-03-04 2014-09-10 腾讯科技(深圳)有限公司 IOS system transparent agent realization method and system
CN110753020A (en) * 2018-07-24 2020-02-04 北京京东尚科信息技术有限公司 Network request processing method and device

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104023046B (en) * 2014-05-08 2018-03-02 深信服科技股份有限公司 Mobile terminal recognition method and device
CN105939313B (en) * 2015-09-01 2019-03-15 杭州迪普科技股份有限公司 Status code reorientation method and device

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104038510A (en) * 2013-03-04 2014-09-10 腾讯科技(深圳)有限公司 IOS system transparent agent realization method and system
CN110753020A (en) * 2018-07-24 2020-02-04 北京京东尚科信息技术有限公司 Network request processing method and device

Also Published As

Publication number Publication date
CN112351064A (en) 2021-02-09

Similar Documents

Publication Publication Date Title
US7809376B2 (en) Enhanced analogue of interactive voice response structures and functions for mobile phones and similar handheld communications devices
WO2016173348A1 (en) Network access method and mobile communications terminal
CN102348017B (en) Calling method of terminal application, terminal device and UICC (Universal Integrated Circuit Card)
US20040054745A1 (en) Method of supporting multiple languages for a mobile communication terminal and a communication system for the same
EP1552675A2 (en) Mobile-initiated number information query and delivery
CN103377652A (en) Method, device and equipment for carrying out voice recognition
US20050021767A1 (en) Keeping persistency while switching between modalities
CN105681561B (en) Ad blocking device and method
US11044367B2 (en) Single interface for provisioning collected data to requesting systems
CN103577420A (en) Method and device for inquiring user information dynamically
CN113434910A (en) Business data chaining method and device
US20180376335A1 (en) Method and device for realizing wireless access point connection authentication
WO2021129446A1 (en) Network searching method and device, and storage medium
US20160165048A1 (en) Methods and systems for automated business dialing
CN105959934A (en) Repeated network access identification method and system
CN112351064B (en) Method for redirecting network request by iOS (Internet operating System) by using AFNetworking
US20120324053A1 (en) Method and device for processing service command information
CN110519810B (en) Service relay switching method, terminal equipment, storage medium and device
CN105100514A (en) Caller ID analyzing-reminding method and system based on cloud server database
US10616418B2 (en) Dynamically generated call triggers
JP5595252B2 (en) Cooperation support apparatus, program, cooperation support method, cooperation support system, and communication apparatus
JP6197112B2 (en) Automatic carrier detection for mobile network devices
KR20160032653A (en) Method and apparatus for ranking candiate character and method and device for inputting character
KR20050034680A (en) A telephone number guidance system which uses a character message.
KR20170143261A (en) Operating method of intelligent network server and chatting server for switching between telephone counseling and chatting counseling in intelligent network environment, and intelligent network server and chatting server thereof

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant