用户中止后在后台运行PHP + Curl

我有一个在线商店,我使用一个在线记帐软件在其中手动发布订单。在线会计软件具有很大的api,我想在客户下订单时自动发送订单。

订单完成后,客户就会登陆成功页面,即successpage.php

在此页面中,我有以下内容:

$sendOrder = file_get_contents("https://myonlinestore.com/sendorder.php?order=1234");

在sendorder.php上,我收到$_GET参数“ order”,它是订单号,并且我处理了几个SQL请求以从数据库中检索订单的数据。

一旦获得了所有这些数据,我便启动一个CURL发布以使用会计系统的API发送数据。

这是我的代码的精简版本,其中包含基本部分:

$orderNum = htmlspecialchars($_GET["order"]) // SENT OVER FILE_GET_CONTENTS

// bOf process SQL here and get order info stored in various variables
// EXECUTE SQL HERE
// eOf process SQL here and get order info stored in various variables

$invoice = array(
'customer_id' => $custaccount,'estimate_number' => $orderRef,'reference_number' => $orderNum
// MANY OTHER VARIABLES ENTERED HERE,BUT LEFT OUT TO KEEP THINGS SHORT
);

$jsonInvoice = json_encode($invoice);


$url = 'https://accOUTINGAPP.com/api/v2/orders';

$data = array(
'authtoken'  => '***********','JSONString'  => $jsonInvoice,'company_id' => '***********'     

);


$ch = curl_init($url);
curl_setopt($ch,CURLOPT_VERBOSE,1);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,FALSE);
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,FALSE); 
curl_setopt($ch,CURLOPT_POSTFIELDS,http_build_query($data));
curl_setopt($ch,CURLOPT_RETURNTRANSFER,TRUE);
curl_setopt($ch,CURLOPT_POST,CURLOPT_HTTPHEADER,array("Content-Type: application/x-www-form-urlencoded") );

$response = false;

$response = curl_exec($ch);
curl_close($ch);


// TEST RESPONSE

if($response !== false) {

var_dump($response);
}
else
{
echo "oops error hehehe";
}

我的主要担忧:

我希望用户一旦进入successpage.php,就立即关闭其标签或页面。

但是我想确保Successpage.php的$ sendOrder = file_get_contents()及其在sendorder.php上执行的代码无论用户连接如何都可以继续运行。

所以我的问题是,我应该放在哪里:

ignore_user_abort(TRUE);

我还应该使用输出缓冲吗?我之所以这么问,是因为我在其他网站上读了一篇有关此事的帖子,并提出了建议。

最后,我应该包括:

set_time_limit(0);
zhuyudiao 回答:用户中止后在后台运行PHP + Curl

请尽快致电>>> from django.contrib.auth.hashers import check_password,UnsaltedMD5PasswordHasher >>> from legacy.hashers import PBKDF2WrappedMD5PasswordHasher >>> hasher = PBKDF2WrappedMD5PasswordHasher() >>> test_pwd = '123456' >>> test_pwd_unsalted_md5 = UnsaltedMD5PasswordHasher().encode(test_pwd,salt='') >>> print(test_pwd_unsalted_md5) '827ccb0eea8a706c4c34a16891f84e7b' # this is an example of a password I want to upgrade >>> upgraded_test_pwd = hasher.encode_md5_hash(test_pwd) >>> print(upgraded_test_pwd) pbkdf2_wrapped_md5$150000$f3aae83b02e8727a2477644eb0aa6560$brqCWW5QuGUoSQ28YNPGUwTLEwZOuMNheN2RxVZGtHQ= >>> check_password(test_pwd,upgraded_test_pwd) False 。而且,您不需要输出缓冲,因为一旦关闭浏览器选项卡,任何人都不会看到您的输出,因此,您只需确保脚本已经执行任何操作就可以继续。

本文链接:https://www.f2er.com/2933977.html

大家都在问