0我正在尝试将用户重定向到'Thank You'页面成功,我正在使用简单的php重定向。
header('Location: http://client.com/thank-you-one.php');
并且我已将其添加到下面的代码段中,但重定向仍然无法正常工作,如果有人知道为什么或者可以看到我出错的地方我会喜欢一些反馈。
$username = '*****';
$password = '*****';
//POPULATE THESE (and other fields) WITH REQUEST DATA
$first_name = $_POST['firstname'];
$last_name = $_POST['lastname'];
$email = $_POST['emailaddress'];
$company_name = $_POST['companyname'];
$date_of_birth = (''.$_POST['year'].'-'.$_POST['month'].'-'.$_POST['day'].'');
$loyalty_number = $_POST['membernumber'];
$host = 'http://api.client.com/users';
$user_curl = curl_init($host);
curl_setopt($user_curl, CURLOPT_HTTPHEADER, array('Accept: application/vnd.aardvark.crm+json; version=1.3'));
curl_setopt($user_curl, CURLOPT_USERPWD, $username.":".$password);
curl_setopt($user_curl, CURLOPT_TIMEOUT, 30);
curl_setopt($user_curl, CURLOPT_POST, 1);
curl_setopt($user_curl, CURLOPT_POSTFIELDS, http_build_query(array('forename' = > $first_name, 'surname' = > $last_name, 'email' = > $email, 'company_name' = > $company_name, 'date_of_birth' = > $date_of_birth, 'loyalty_number' = > $loyalty_number)));
curl_setopt($user_curl, CURLOPT_RETURNTRANSFER, TRUE);
$return = curl_exec($user_curl);
$info = curl_getinfo($user_curl);
if ($info['http_code'] == '200') {
$data = json_decode($return, true);
$tag_curl = curl_init($host.'/'.$data['id'].'/tags/'.$_POST['favorite'].'');
curl_setopt($tag_curl, CURLOPT_HTTPHEADER, array('Accept: application/vnd.aardvark.crm+json; version=1.3'));
curl_setopt($tag_curl, CURLOPT_USERPWD, $username.":".$password);
curl_setopt($tag_curl, CURLOPT_TIMEOUT, 30);
curl_setopt($tag_curl, CURLOPT_POST, 1);
curl_setopt($tag_curl, CURLOPT_RETURNTRANSFER, TRUE);
$tag_return = curl_exec($tag_curl);
$ml_curl = curl_init($host.'/'.$data['id'].'/mailinglists/3');
curl_setopt($ml_curl, CURLOPT_HTTPHEADER, array('Accept: application/vnd.aardvark.crm+json; version=1.3'));
curl_setopt($ml_curl, CURLOPT_USERPWD, $username.":".$password);
curl_setopt($ml_curl, CURLOPT_TIMEOUT, 30);
curl_setopt($ml_curl, CURLOPT_PUT, 1);
curl_setopt($ml_curl, CURLOPT_RETURNTRANSFER, TRUE);
$tag_return = curl_exec($ml_curl);
header('Location: http://client.com/thank-you-one.php');
echo 'test1';
exit;
} else {
//analyse resonse with
$data = json_decode($return, true);
print_r($data);
echo 'test2';
}
curl_close($user_curl);
curl_close($tag_curl);
curl_close($ml_curl);
答案 0 :(得分:0)
我认为您的问题是您对http_code
201
的测试。将其更改为200
if ($info['http_code'] == '200')
{