最近中文字幕高清中文字幕无,亚洲欧美高清一区二区三区,一本色道无码道dvd在线观看 ,一个人看的www免费高清中文字幕

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

PHP接收和發(fā)送數(shù)據(jù)

PHP接收和發(fā)送數(shù)據(jù)

PHP
慕尼黑8549860 2023-06-18 17:05:54
我有以下 php 代碼,它將數(shù)據(jù)發(fā)送到潛在客戶工具。<?php$curl = curl_init();curl_setopt_array($curl, array(  CURLOPT_URL => "https://mkt.university-private.internal/form/submit",                                                                                                                                                                                                                                                                                                                                                                           CURLOPT_RETURNTRANSFER => true,  CURLOPT_ENCODING => "",  CURLOPT_MAXREDIRS => 10,  CURLOPT_TIMEOUT => 0,  CURLOPT_FOLLOWLOCATION => true,  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,  CURLOPT_CUSTOMREQUEST => "POST",  CURLOPT_POSTFIELDS => array('mauticform[f_email]' => 'gbsilva@gmail.com','mauticform[f_name]' => 'Gabriel','mauticform[formId]' => '5'),  CURLOPT_HTTPHEADER => array(    "X-Forwarded-For: 91.92.103.192"  ),));$response = curl_exec($curl);curl_close($curl);echo $response;問(wèn)題是我必須在 php 腳本中手動(dòng)輸入數(shù)據(jù)。我現(xiàn)在有一個(gè) CRM,它執(zhí)行 POST 并以正文形式數(shù)據(jù)發(fā)送以下數(shù)據(jù):email=gbsilva@40gmail.com&name=Gabriel&IP=91.92.103.192&formId=5我需要的是我的 PHP 代碼接受接收具有上述這些值的 CRM 帖子,并使用來(lái)自 CRM 的數(shù)據(jù)在我的潛在客戶工具中發(fā)出請(qǐng)求。在我的 erp 上,我可以調(diào)用一個(gè) url,我將調(diào)用我的 script.php 的 url他需要在發(fā)送轉(zhuǎn)換之前將字段的名稱放在這個(gè)命名法之間,leads 工具只接受具有這個(gè)命名法的字段:mauticform[f_FIELDNAME]誰(shuí)能幫忙
查看完整描述

2 回答

?
互換的青春

TA貢獻(xiàn)1797條經(jīng)驗(yàn) 獲得超6個(gè)贊

非常簡(jiǎn)單只需要利用$_POST將值傳遞給變量然后使用它


<?php


$P_email = $_POST['email'];

$P_name = $_POST['name'];

$P_formId = $_POST['formId'];

$P_ip = $_POST['IP'];


$curl = curl_init();


curl_setopt_array($curl, array(

  CURLOPT_URL => "https://mkt.university-private.internal/form/submit",   

  //..hidden                                                                                                                                                                                                                   

  CURLOPT_POSTFIELDS => array('mauticform[f_email]' => $P_email,'mauticform[f_name]' => $P_name,'mauticform[formId]' => $P_formId),


  //hidden


  //*update* FOR IP

  CURLOPT_HTTPHEADER => array(

    "X-Forwarded-For: $P_ip"

  ),

));



//..

更新:所以要解決動(dòng)態(tài)變量名稱


//Create an array to hold the name=value pairs

$P_arr = [];

//Loop over $_POST and populate $P_arr

foreach($_POST as $key=>$value){

    $P_arr[$key] = $value; 

   // $key will run through all those keys' values you sent //name ,email ..

   // so will $value but on the literals like "gbsilva@40gmail.com", "Gabriel"

}


/* We have now an array of key value pairs */

// adjust the KEYs to "mauticform"'s format before using

$mauticformArr = [];


foreach($P_arr as $key=>$value){

   if($key != 'IP'){

      if($key!= 'formId')

        $mauticformArr['mauticform[f_'.$key .']'] = $value;

      else

        $mauticformArr['mauticform['.$key .']'] = $value;       

   }

}


// Then use inside you code as

curl_setopt_array($curl, array(

  CURLOPT_URL => "https://mkt.university-private.internal/form/submit",   

  //..hidden                

CURLOPT_POSTFIELDS => $mauticformArr,

  //..hidden 

  //..


查看完整回答
反對(duì) 回復(fù) 2023-06-18
?
慕慕森

TA貢獻(xiàn)1856條經(jīng)驗(yàn) 獲得超17個(gè)贊

您可能會(huì)發(fā)現(xiàn)“Guzzle”比實(shí)際使用 CURL 效果更好......



查看完整回答
反對(duì) 回復(fù) 2023-06-18
  • 2 回答
  • 0 關(guān)注
  • 180 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)