Home  >  Article  >  Backend Development  >  An interface callback and the problem of receiving callback information_PHP tutorial

An interface callback and the problem of receiving callback information_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:51:411743browse




An interface callback and the problem of receiving callback information

An interface callback and the problem of receiving callback information

This is the problem. When I interface with an agent, the user of the agent comes to me and the user logs in after successful verification.

The original design is

$url = 'http://www.1234.com/123.php?'.$PassportNotify;
$html = file_get_contents($url);

Then this $html returns a string re=0&msg=success

I ask the user to log in based on re=0 and refuse to log in if re=1


The problem now is that there may be a problem with the network communication between the servers, that is, the user is asked to log in regardless of re=0 or re=1
Then if re=1, it will send callback information to the other party's server until re=0 is received, which is somewhat similar to the asynchronousness of the Alipay interface

But I don’t know how to implement this method in the program. Thank you for your advice, thank you!

Let me answer




D8888D reply content------------------------------------------------- ----------
First of all, this call is inappropriate here. This is not called a callback
LZ go and see what is called a callback

In my opinion, it is the simplest while loop. Nothing difficult?

D8888D reply content------------------------------------------------- ----------
How to verify, GET or POST? For POST, file_get_contents alone cannot complete the task.

D8888D reply content------------------------------------------------- ----------
It is to send a complete URL address to the other party's server, and the other party's server will return a string. I accept this string to make a judgment. What is the best way to use this operation? I feel that it takes a long time to use file_get_contents. Is there any good way? Thank you

D8888D reply content------------------------------------------------- ----------
I just want to get a string from the other party's server address, and then get the return value. Is there any good way? Thank you!

D8888D reply content------------------------------------------------- ----------
simplexml_load_file

Server output xml [img]http://www.111cn.cn/bbs/images/smilies/default/lol.gif[/img]

Take a look at yahoo API

D8888D reply content------------------------------------------------- ----------
for($count =1; $count++; $count
$html = file_get_contents($url);
parse_str($html);
print_r($re);

if($re == 0){
break;
}

Is this okay?

D8888D reply content------------------------------------------------- ----------
do {

$html = file_get_contents($url);

}while($html!=0);


Copy code

D8888D reply content------------------------------------------------- ----------
file_get_contents sends a URL to the other party's server and gets a response. It takes more than a minute to loop five times. It's so slow. Is there any other way?

D8888D reply content------------------------------------------------- ----------
Come on!


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632540.htmlTechArticleThe problem of an interface callback and receiving callback information. The problem of an interface callback and receiving callback information is this problem, and The agent makes the interface, and the users of the agent come to me for verification...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn