curl无法在实时服务器上运行,但在本地主机上运行

时间:2018-12-01 08:25:18

标签: php api curl

请帮助我解决这个问题。 那在我的本地服务器上工作...但不在我的服务器上工作...只是返回null。甚至我都认为这不适用于输入请求,但对静态数据也显示相同的结果。那可能是PHP版本问题吗? 这是所有附加在代码上的信息...我认为这对测试很有帮助。

<?php

$mmsg = '';

$name1 = "monirul";
$lastname1 = "islam";
$email1 = "helloKitty77269@gmail.com";
$phone1 = "676787888";
$pref1 = "ES";

$mainPhone = "34";

$getIp = "1.1.1.1";

$url = 'http://partners.cheetah.solutions:18020/CreateContact';

  // Raw data to send
  $fields = array(
    "LeadSourceCode"    =>"27009",
    "LeadOwnershipCode" =>"108",
    "BrandCode"         =>"GENERAL",
    "FirstName"         =>$name1,
    "LastName"          =>$lastname1,
    "EmailAddress"      =>$email1,
    "PhoneCountryCode"  =>$mainPhone,
    "PhoneNumber"       =>$mainPhone.$phone1,
    "IpAddress"         =>$getIp,
    "ReferalUrl"        =>"https://raionventures.com/files/raion_download_it03.php",
    "SelectedCountryIso"=>$pref1
  );

  $body = json_encode($fields);

  $curlnew = curl_init();

  curl_setopt_array($curlnew, array(
  CURLOPT_PORT => "18020",
  CURLOPT_URL => $url,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => $body,
  CURLOPT_HTTPHEADER => array(
    "Authorization: Basic RHVrZTo1NTZiZDRlN2FiYTM3N2JiZDY4ZTUwYTVkZmU3NzdmZQ==",
    "Content-Type: application/json",
    "Postman-Token: 0e706db8-76cd-4f26-90bc-920623a1d816",
    "cache-control: no-cache"
  ),
));

$responseForApi = curl_exec($curlnew);
$errnew = curl_error($curlnew);
$ano = json_decode($responseForApi, true);


if ($ano['IsSuccess'] == "true") {
    $mmsg = "Success!<br>Your Client id: ".$ano['ContactId'];
}else{
    $mmsg = $ano['ErrorMessage'];
}

header("Content-Type: application/json");
echo json_encode($mmsg);

0 个答案:

没有答案