2017-06-26 9 views
0

こんにちは私は大きな問題を抱えています.3人のPHP開発者はすべてコードが正しいと言いますが、フォームから別のcrmウェブサイトにデータを投稿していません。 - それは明らかに全体のポイントです!誰かがフォームを提出すると自分のレコードが自分のcrmシステムで作成されるようにしますWordpressを使ってCurl

私は自分のcrmシステムにデータを送信したいと思っています。

WordPressがどのように動作するかを伝えるのに問題があると思います。私は技術者ではないので、私の知識と理解は少し薄いです。今のところ、コードには200のコードが含まれていると思います。つまり、crmシステムのもう一方の端にデータがないということです。誰かが間違っている点を指摘できますか?

(PSポスティングのURLは、ちょうどので、私はここでのプライバシー規則を破るいけない、私はそれだけでも通じ姓を送信するために得ることができるかどうかだけを参照する項目の//多くをエコーし​​ているPPSを変更)

ボックス内の数字は、データが収集されたデータを見たときにプロがどれほど手に入るかを示しています。つまり、姓が[861]の場合、カールが問題を引き起こしているか、カールがデータを送信しているかですか? 'コードスニペットを' ワードプレスPHPコードを有効にする

コード......... 'after_entry_created'

add_action( 'frm_after_create_entry'、30、のためのPHPプラグインを使用して

PPS 2)。 after_entry_created 機能($ entry_idに、$ form_id){

if($form_id == 21){ 

$url = 'https://secure4.mline.co.uk/DavidFarrell/php/NewMortgage.php'; 
$fields = array(
    //Mandatory fields go here: 
    'MortgageMode' => urlencode(1), // OR 'CommercialMode => urlendcode(1), for CommercialKeeper 
    'StagePK' => urlencode(25), 
    'AdvisorPK' => urlencode(1), 
    'Surname1'=>urlencode($_POST['[861]']), 

    //Other fields to post into go here: 

//Mortgage Details 
//'LenderPK'=>urlencode(1), 
//'InterestRateTypePK'=>urlencode(2), 
//'Rate'=>urlencode(3.45), 
//'DealTerm'=>urlencode(5), 
//'Term'=>urlencode(25), 
//'ActionPK'=>urlencode(11), 
//'ActionText'=>urlencode($_POST['Notes']), 

//Applicant Details 
//'Forename1'=>urlencode($_POST['859']), 
//'Email1'=>urlencode($_POST['Emailaddress'][864]), 
//'DayPhone'=>urlencode($_POST['[867]']), 
//'MobilePhone'=>urlencode($_POST['MobilePhone1'][866]), 
//'Forename2'=>urlencode($_POST['[880]']), 
//'Surname2'=>urlencode($_POST['[882]']), 
//'MidNameApp1'=>urlencode($_POST['[860]']), 
//'MidNameApp2'=>urlencode($_POST['[881]']), 

    //Submit is also mandatory and typically is placed at the end of your array 
'submit'=>true 
); 

// Loops through the $fields array and results in a string variable called $fields_string which is a URL friendly string 
foreach($fields as $key => $value) 
{ 
    //adds the key which is the eKeeper field followed by an '=', followed by and ampersand (&) 
    $fields_string.=$key.'='.$value.'&';  
} 
//trims any whitespace and cleans up the $fields_string variable 
rtrim($fields_string,'&'); 

// Initialises a cURL connection 
$ch = curl_init(); 


//Sets the URL to post into using the $url variable that was initialised earlier 
curl_setopt($curl_connection, CURLOPT_POST, 1); 
curl_setopt($ch,CURLOPT_URL,$url); 
// Sets the number of fields to be passed, this is achieved by using the count() function to count the elements in the $fields array. 
//curl_setopt($ch,CURLOPT_POST,count($fields)); 
// Sets the string that contains the eKeeper fields and their values ($fields_string) 
curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string); 
//curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string); 
// Sets the return transfer option to true so that the return value after execution 
    // curl_setopt($ch,CURLOPT_RETURNTRANSFER,true); 
    curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, false); 

// Executes the curl session. must not be done until after the session has been initilised and the relevant curl options have been set. 
$result = curl_exec($ch); 

// Closes the connection/curl session 
curl_close($ch); 
} 

}

+0

カール情報/エラーの情報はありますか? $ info = curl_getinfo($ ch); $エラー= curl_error($ ch); – BenRoob

+0

考えられる原因。 'curl'はあなたの' https証明書 'に問題があります。 'CURLOPT_SSL_VERIFYHOST'オプションを' 0'に追加して、それが何か違いがあるかどうか確認してください。 (http://php.net/manual/en/function.curl-setopt.php)。また、 'curl_getinfo'でエラーをチェックしてください。 –

答えて

0

も、この部分は間違いなく間違っている

foreach($fields as $key => $value) 
{ 
    //adds the key which is the eKeeper field followed by an '=', followed by and ampersand (&) 
    $fields_string.=$key.'='.$value.'&';  
} 
//trims any whitespace and cleans up the $fields_string variable 
rtrim($fields_string,'&'); 

キーや値のいずれもがURLエンコードされ、もしそうならキーまたは値にÆØÅまたはスペースまたは&などの文字が含まれていると、エンコードが正しく行われません。また、rtrimはurlencodeされた文字列をどうやってトリミングするかではなく、どうやって3デベロッパーとなったのか分かりません。

$fields_string.=http_build_query($fields); 

:それは

foreach($fields as $key => $value) 
{ 
    $fields_string.=urlencode($key).'='.urlencode($value).'&';  
} 
if(!empty($fields)){ 
    //remove the last & 
    $fields_string=substr($fields_string,0,-1); 
} 

幸いにも、PHPはhttp_build_query呼ばx-www-form-urlencoded -formatted文字列を作るための組み込み関数を持っているので、コード全体を置き換えることができただろう修正

これは基本的にあなたのエンコーディングループ全体を行います。それ以外の未定義の変数がたくさんあるのですが、それらのコードはほとんどが削除されていると思います(ここに投稿する前に束を取り除いたとします)。もしそうでなければ、php.iniのerror_reporting=E_ALLを設定すると、それらのほとんどは(配列ではなく、PHPは愚かであるため配列は暗黙のうちにプッシュされて警告なしに作成されます)

しかし、これまでに何度も言いましたように、curlリクエストをデバッグするときは常にCURLOPT_VERBOSEを有効にしてください。あなたのメインポストにCURLOPT_VERBOSE stderrログを投稿してください。そのログでは、より多くの援助が必要な場合があります。

関連する問題