


Introduction to curl requesting other interfaces in the php interface
This article mainly introduces the introduction of curl requesting other interfaces in the PHP interface. It has a certain reference value. Now I share it with you. Friends in need can refer to it.
Today I encountered a need to write The requirements for curl are as follows:
System A (shopping system) and system B (answering system) of the same application are independent of each other, and all user data exists in the database of system A.
Now we are in an operation in system B. We need to verify in system B whether the person currently requesting is a member of this application. To verify whether he is a
member of this application, of course we need to get the current user's Compare the logo to the database, but the database is in system A. At that time, I thought of curl and drew a picture:
In fact, to put it bluntly, it is to simulate http requests. , because unlike the front-end, http requests can be initiated directly through ajax or other methods, and the back-end has to
simulate this request through curl in order to achieve the same effect as the front-end.
So Baidu searched for a PHP curl method and encapsulated it:
1 2 3 4 5 6 7 8 9 |
|
Then I happily called it:
1 2 3 |
|
Here is a verify interface that simulates requesting system A in system B interface to review the user identity, and then determines system B based on the review results
What the interface returns to the outside world.
When I finally ran the B system interface, I found that in addition to the return value of the B system interface, it was also mixed with the return value of the A system interface (verify).
It was very confusing for a while. I was puzzled. I looked around to see what was wrong with the return value of the verify interface. exit(json_encode(array("a"=>a))) didn't work, so I replaced it with
return array("a" =>a); Still didn’t work, so I changed it to var_dump(array("a"=>a)); and it still didn’t work! ! ! Still returns the return values of the two interfaces.
Later, later, I debugged the encapsulated curl function sentence by sentence, and found that the value of the verify interface had been printed directly in the red letter above,
So Baidu keyword: curl is not direct Output; blah blah, a bunch of related information came out. I opened one at random and found the answer. It turned out that curl master
set a parameter:
1 |
|
In the end, the problem was solved, and it can be regarded as a small knowledge point about the curl parameter setting of PHP~~~
The above is the entire content of this article, I hope it will be helpful to everyone's learning, more related Please pay attention to the PHP Chinese website for content!
Related recommendations:
How to verify the legality of IP in PHP
##How to implement simulated multiple inheritance in PHP
The above is the detailed content of Introduction to curl requesting other interfaces in the php interface. For more information, please follow other related articles on the PHP Chinese website!

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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

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

In today's context where data visualization is becoming more and more important, many developers hope to use various tools to quickly generate various charts and reports so that they can better display data and help decision-makers make quick judgments. In this context, using the Php interface and ECharts library can help many developers quickly generate visual statistical charts. This article will introduce in detail how to use the Php interface and ECharts library to generate visual statistical charts. In the specific implementation, we will use MySQL

How to combine ECharts and PHP interfaces to implement dynamic updates of statistical charts Introduction: Data visualization plays a vital role in modern applications. ECharts is an excellent JavaScript chart library that can help us easily create various types of statistical charts. PHP is a scripting language widely used in server-side development. By combining ECharts and PHP interfaces, we can realize dynamic updating of statistical charts, so that charts can be automatically updated according to changes in real-time data. Book

How to display real-time statistical charts through ECharts and PHP interfaces. With the rapid development of the Internet and big data technology, data visualization has become an important part. As an excellent open source JavaScript data visualization library, ECharts can help us display various statistical charts simply and efficiently. This article will introduce how to display real-time statistical charts through ECharts and PHP interfaces, and provide relevant code examples. 1. Preparation Before starting, we need to do some preparations

The SPL interface includes Iterator, Countable and ArrayAccess in PHP. 1. The Iterator interface makes the object traversable and defines the current(), key(), next(), rewind() and valid() methods. 2. The Countable interface allows the object to report the number of elements and defines the count() method. 3. The ArrayAccess interface allows objects to be accessed and modified like arrays, and defines offsetExists(), offsetGet(), offsetSet() and offsetUnset() methods. These interfaces improve code efficiency and maintainability.

Deeply understand the definition and usage of PHP interfaces. PHP is a powerful server-side scripting language that is widely used in the field of web development. In PHP, interface is an important concept that can be used to define the specifications of a set of methods without caring about the specific implementation of the methods. This article will delve into the definition and use of PHP interfaces and provide specific code examples. 1. What is an interface? In object-oriented programming, an interface is an abstract concept that defines the specification of a set of methods, but has no specific

How to implement data verification and verification of statistical charts through ECharts and PHP interfaces. As the demand for data visualization increases, ECharts has become a very popular data visualization tool. As a common back-end scripting language, PHP is also widely used in web development. This article will introduce how to implement data verification and verification of statistical charts through ECharts and PHP interfaces, and provide specific code examples. First, we need to understand ECharts. ECharts is an open source software developed by Baidu

In modern applications, visualization of data is becoming more and more popular. Statistical charts are a great way to visualize data and can easily help users understand trends in data. ECharts is a powerful front-end chart framework that provides rich chart types and interactive functions. Php is a very popular backend language that makes it easy to generate dynamic content and interfaces. In this article, we will introduce how to use the PHP interface and ECharts to generate interactive statistical charts, and provide specific code examples. one,

How to use the PHP interface and ECharts to implement data screening and filtering of statistical charts requires specific code examples. In data visualization, using statistical charts is a common way to display data. In practical applications, data often needs to be screened and filtered to meet different needs. The PHP interface and ECharts are two widely used tools through which data filtering and filtering of statistical charts can be implemented. The following will use an example to demonstrate how to use the PHP interface and ECharts implementation
