


Notes and precautions for calling the interface on PC, precautions in late pregnancy, precautions when flying, precautions after miscarriage
data-id="1190000004902725">
Preface
Good habits create a good life, and you must be good at summarizing during development. Today I will continue to share some useful information with you. Fans who follow me will benefit from it. Below are some notes I compiled when calling the interface on the PC, as well as reminders of things you need to pay attention to!
Cause Analysis
1. First, let me talk about why the interface is called on the PC side to obtain data!
I’ll give you a link: http://www.bitscn.com/pdb/php/201411/402…. After reading this article, you will probably understand what I mean.
2. Integrating relevant information is not only conducive to the acquisition of information, but also serves as a lesson for others. People who have planted trees can benefit future generations, right? Haha, I am a philanthropist.
Note organization
1. Three ways for Yii2 PC to call the interface to obtain data
PHP method to call the Api interface
<code> 1、直接在方法里引用接口的url。 2、通过file_get_contents()函数获取url的数据。 3、把获取到的JSON格式数据进行反转。(可选) 4、参考网址:http://www.jb51.net/article/20705.htm //PHP远程调用URL 例: $url='http://api.xxx.com/v1/departments?id=list&company_id=1'; $data=file_get_contents($url); $data_1 = json_decode($data,true); //JSON反转</code>
Ajax method to call the Api interface
<code> 例: $.ajax({ type:"POST", url: //你的请求程序页面随便啦(接口地址) async:false,//同步:意思是当有返回值以后才会进行后面的js程序。 data://请求需要发送的处理数据 success:function(msg){ if (msg) {//根据返回值进行跳转 window.location.href = '你的跳转的目标地址(页面地址)'; } }</code>
JQ method to call the Api interface
<code>例: <script type="text/javascript" src="/apihandonesvn/frontend/web/assets/68738eee/jquery-1.11.2.min.js"></script> <script type="text/javascript"> //1、GET方式 $.get('http://api.XXX.com/v1/departments?grade=1',function(data){ // console.log(data);//输出内容,类似alert() $('#content').html(data); }); //2、POST方式 $.post('http://api.XXX.com/v1/departments?grade=1',{a:1,b:2,c:3},function(data){ $('#content').html(JSON.stringify(data)); }); </script></code>
Added: If you use the latter two methods, add the following code at the top of all methods of the controller corresponding to the interface
<code> public function behaviors() { return ArrayHelper::merge([ [ 'class' => Cors::className(), 'cors' => [ 'Origin' => ['http://www.ceshi.com'],//PC端的Url 'Access-Control-Request-Method' => ['GET','POST','PUT','DELETE', 'HEAD', 'OPTIONS'], ], 'actions' => [ 'index' => [ 'Access-Control-Allow-Credentials' => true, ] ] ], ], parent::behaviors()); }</code>
The above three methods of calling the interface on the PC side have been tested by me and are all feasible. You can choose what you like.
2. When calling the interface on the PC, how does the interface obtain the uid?
At this time, the interface cannot be obtained using Yii:$app->user->id that comes with Yii, because it is impossible to log in through the interface. To obtain the uid of the current logged-in user through the interface, you can pass an access-token through the PC, and then use get on the interface to find out the uid and solve the problem.
This method can also be imitated when the interface obtains other parameters.
3. Report: PHP Warning – yiibaseErrorException
Invalid argument supplied for foreach() error problem and solution
This error is caused by looping empty data. As long as a judgment must be added before the data is looped to ensure that the data exists before the loop can be looped. solved. Although this is not a particularly difficult error to solve, we still have to pay attention to details, as details determine success or failure.
Reminder
1. The PC calls the interface for local testing. It is best not to match the local interface address with the Internet, because then it will go to the local interface first. If the local interface is good, it is difficult to find the reason.
Related information
PHP (CURL) POST data calling API simple example: http://eyexiaobo.iteye.com/blog/1100712
The above introduces the notes and precautions for calling the interface on the PC side, including precautions and interface content. I hope it will be helpful to friends who are interested in PHP tutorials.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



When we assemble the computer, although the installation process is simple, we often encounter problems in the wiring. Often, users mistakenly plug the power supply line of the CPU radiator into the SYS_FAN. Although the fan can rotate, it may not work when the computer is turned on. There will be an F1 error "CPUFanError", which also causes the CPU cooler to be unable to adjust the speed intelligently. Let's share the common knowledge about the CPU_FAN, SYS_FAN, CHA_FAN, and CPU_OPT interfaces on the computer motherboard. Popular science on the CPU_FAN, SYS_FAN, CHA_FAN, and CPU_OPT interfaces on the computer motherboard 1. CPU_FANCPU_FAN is a dedicated interface for the CPU radiator and works at 12V

As a modern and efficient programming language, Go language has rich programming paradigms and design patterns that can help developers write high-quality, maintainable code. This article will introduce common programming paradigms and design patterns in the Go language and provide specific code examples. 1. Object-oriented programming In the Go language, you can use structures and methods to implement object-oriented programming. By defining a structure and binding methods to the structure, the object-oriented features of data encapsulation and behavior binding can be achieved. packagemaini

During the Mingchao test, please avoid system upgrades, factory resets, and parts replacement to prevent information loss and abnormal game login. Special reminder: There is no appeal channel during the testing period, so please handle it with caution. Introduction to matters needing attention during the Mingchao test: Do not upgrade the system, restore factory settings, replace equipment components, etc. Notes: 1. Please upgrade the system carefully during the test period to avoid information loss. 2. If the system is updated, it may cause the problem of being unable to log in to the game. 3. At this stage, the appeal channel has not yet been opened. Players are advised to choose whether to upgrade at their own discretion. 4. At the same time, one game account can only be used with one Android device and one PC. 5. It is recommended that you wait until the test is completed before upgrading the mobile phone system or restoring factory settings or replacing the device.

With the rise of short video platforms, Douyin has become an indispensable part of many people's daily lives. Live broadcasting on Douyin and interacting with fans are the dreams of many users. So, how do you start a live broadcast on Douyin for the first time? 1. How to start a live broadcast on Douyin for the first time? 1. Preparation To start live broadcast, you first need to ensure that your Douyin account has completed real-name authentication. You can find the real-name authentication tutorial in "Me" -> "Settings" -> "Account and Security" in the Douyin APP. After completing the real-name authentication, you can meet the live broadcast conditions and start live broadcast on the Douyin platform. 2. Apply for live broadcast permission. After meeting the live broadcast conditions, you need to apply for live broadcast permission. Open Douyin APP, click "Me"->"Creator Center"->"Direct

Introduction to PHP interface and how it is defined. PHP is an open source scripting language widely used in Web development. It is flexible, simple, and powerful. In PHP, an interface is a tool that defines common methods between multiple classes, achieving polymorphism and making code more flexible and reusable. This article will introduce the concept of PHP interfaces and how to define them, and provide specific code examples to demonstrate their usage. 1. PHP interface concept Interface plays an important role in object-oriented programming, defining the class application

The reason for the error is in python. The reason why NotImplementedError() is thrown in Tornado may be because an abstract method or interface is not implemented. These methods or interfaces are declared in the parent class but not implemented in the child class. Subclasses need to implement these methods or interfaces to work properly. How to solve this problem is to implement the abstract method or interface declared by the parent class in the child class. If you are using a class to inherit from another class and you see this error, you should implement all the abstract methods declared in the parent class in the child class. If you are using an interface and you see this error, you should implement all methods declared in the interface in the class that implements the interface. If you are not sure which

Interfaces and abstract classes are used in design patterns for decoupling and extensibility. Interfaces define method signatures, abstract classes provide partial implementation, and subclasses must implement unimplemented methods. In the strategy pattern, the interface is used to define the algorithm, and the abstract class or concrete class provides the implementation, allowing dynamic switching of algorithms. In the observer pattern, interfaces are used to define observer behavior, and abstract or concrete classes are used to subscribe and publish notifications. In the adapter pattern, interfaces are used to adapt existing classes. Abstract classes or concrete classes can implement compatible interfaces, allowing interaction with original code.

As a new operating system launched by Huawei, Hongmeng system has caused quite a stir in the industry. As a new attempt by Huawei after the US ban, Hongmeng system has high hopes and expectations. Recently, I was fortunate enough to get a Huawei mobile phone equipped with Hongmeng system. After a period of use and actual testing, I will share some functional testing and usage experience of Hongmeng system. First, let’s take a look at the interface and functions of Hongmeng system. The Hongmeng system adopts Huawei's own design style as a whole, which is simple, clear and smooth in operation. On the desktop, various
