0
Magentoのサードパーティの電子メールサービスとフォームアクションの投稿を統合しようとしていますが、動作していないようです。調査するためにサードパーティサービスに送信する前に、Magentoのエンドで何らかのエラーが発生している可能性を排除したいと考えています。Magento:XML SOAPサードパーティの電子メールサービスとの統合
まず、これが私のHTMLです:
<form action="/external/multisubscribe.php" method="post" width="600px" style="margin: 0 auto;">
\t <table style="text-align: center; vertical-align: middle; width: 100%;">
\t \t <tbody>
\t \t \t <tr>
\t \t \t \t <td style="text-align: center; vertical-align: middle; width:25%; padding: 0 20px 0 20px;">
\t \t \t \t \t <a href="www.example.com/pilotshop/">
\t \t \t \t \t \t <img style="width: 100%; margin: 0 auto;" src="{{media url='wysiwyg/spslogo.png'}}" alt="Pilot Shop" />
\t \t \t \t \t </a>
\t \t \t \t </td>
\t \t \t \t <td style="text-align: center; vertical-align: middle; width:25%; padding: 0 20px 0 20px;">
\t \t \t \t \t <a href="">
\t \t \t \t \t \t <img style="width: 60%; margin: 0 auto;" src="{{media url='wysiwyg/Aflogo.jpg'}}" alt="" />
\t \t \t \t \t </a>
\t \t \t \t </td>
\t \t \t \t <td style="text-align: center; vertical-align: middle; width:25%; padding: 0 20px 0 20px;">
\t \t \t \t \t <a href="">
\t \t \t \t \t \t <img style="width: 60%; margin: 0 auto;" alt="iPad Pilot News" src="/files/2016/03/iPad-Pilot-News-header-544-white-300x99.png" />
\t \t \t \t \t </a>
\t \t \t \t </td>
\t \t \t \t <td style="text-align: center; vertical-align: middle; width:25%; padding: padding: 0 20px 0 20px;">
\t \t \t \t \t <a href="">
\t \t \t \t \t \t <img style="width: 50%; margin: 0 auto;" alt="Student Pilot News" src="/media/wysiwyg/Student-Pilot-News-final-140.png" />
\t \t \t \t \t </a>
\t \t \t \t </td>
\t \t \t </tr>
\t \t \t <tr>
\t \t \t \t <td style="text-align: center; vertical-align: middle; width:25%; padding: 0 20px 0 20px;">
\t \t \t \t \t <p>The online magazine where readers are pilot in command. Opinion, analysis, tips and debate.</p>
\t \t \t \t </td>
\t \t \t \t <td style="text-align: center; vertical-align: middle; width:25%; padding: 0 20px 0 20px;">
\t \t \t \t \t <p>The online magazine where readers are pilot in command. Opinion, analysis, tips and debate.</p>
\t \t \t \t </td>
\t \t \t \t <td style="text-align: center; vertical-align: middle; width:25%; padding: 0 20px 0 20px;">
\t \t \t \t \t <p>Your #1 source for tips, tricks, videos and quizzes about flying with the iPad.</p>
\t \t \t \t </td>
\t \t \t \t <td style="text-align: center; vertical-align: middle; width:25%; padding: 0 20px 0 20px;">
\t \t \t \t \t <p>Everything new pilots need, from free videos to a flight school directory.</p>
\t \t \t \t </td>
\t \t \t </tr>
\t \t \t <tr>
\t \t \t \t <td style="text-align: center; vertical-align: middle; width:25%;">
\t \t \t \t \t <label>
\t \t \t \t \t \t <input style="text-align: center; vertical-align: middle; margin: 0 auto; display: inline-block;" name="pilotshop" type="checkbox" /> Sign Me Up
\t \t \t \t \t </label>
\t \t \t \t </td>
\t \t \t \t <td style="text-align: center; vertical-align: middle; width:25%;">
\t \t \t \t \t <label>
\t \t \t \t \t \t <input style="text-align: center; vertical-align: middle; margin: 0 auto; display: inline-block;" name="airfacts" type="checkbox" /> Sign Me Up
\t \t \t \t \t </label>
\t \t \t \t </td>
\t \t \t \t <td style="text-align: center; vertical-align: middle; width:25%;">
\t \t \t \t \t <label>
\t \t \t \t \t \t <input style="text-align: center; vertical-align: middle; margin: 0 auto; display: inline-block;" name="ipad" type="checkbox" /> Sign Me Up
\t \t \t \t \t </label>
\t \t \t \t </td>
\t \t \t \t <td style="text-align: center; vertical-align: middle; width:25%;">
\t \t \t \t \t <label>
\t \t \t \t \t \t <input style="text-align: center; vertical-align: middle; margin: 0 auto; display: inline-block;" name="learntofly" type="checkbox" /> Sign Me Up
\t \t \t \t \t </label>
\t \t \t \t </td>
\t \t \t </tr> \t \t \t
\t \t </tbody>
\t </table>
\t <div style="text-align:center;vertical-align:center;width:100%;margin-top:3.0em;">
\t \t <input style="text-align: center; vertical-align: middle; margin: 0 auto;" name="email" placeholder="Enter Your Email" type="email" />
\t \t <button style="text-align: center; vertical-align: middle; margin: 0 auto;margin-top:1.200em;" type="submit" name="submit" title="Subscribe" class="button">Subscribe</button>
\t </div>
\t <input name="redirect" value="{{store url="email-subscribe-success"}}" type="hidden" />
\t <input name="action" value="subscribe" type="hidden" />
</form>
そして、これは、この行に変更multisubscribe.php
<?php
include_once "../app/Mage.php";
if(isset($_POST['submit'])) {
$choices = array();
if (isset($_POST['airfacts'])) {
$choices[] = 'airfacts';
}
if (isset($_POST['ipad'])) {
$choices[] = 'ipad';
}
if (isset($_POST['learntofly'])) {
$choices[] = 'learntofly';
}
if (isset($_POST['pilotshop'])) {
$choices[] = 'pilotshop';
}
if (count($choices) == 0) {
echo "Please choose at least one subscription.";
} else {
$email = $_POST['email'];
$email = filter_var($email, FILTER_SANITIZE_EMAIL);
wpSubscription($choices, $email, $_POST['action']);
}
$redirect = $_POST['redirect'];
header('Location: ' . $redirect);
}
function wpSubscription($sites, $email, $action)
{
$mh = curl_multi_init();
$curl_reference_array = array();
$unsubscribe_url_array = array();
foreach ($sites as $site) {
if ($site =='pilotshop') {
$sh_param = array(
'UserName' => "", //Removed user for security purposes
'Password' => "" //Removed pass for security purposes
);
$authvalues = new SoapVar($sh_param, SOAP_ENC_OBJECT);
$headers[] = new SoapHeader("https://webservices.listrak.com/v31/",
'WSUser', $sh_param);
$soapClient = new SoapClient(
"https://webservices.listrak.com/v31/IntegrationService.asmx?WSDL",
array(
'trace' => 1,
'exceptions' => true,
'cache_wsdl' => WSDL_CACHE_NONE,
'soap_version' => SOAP_1_2
)
);
$soapClient->__setSoapHeaders($headers);
$params = array(
'WSContact' => array(
'EmailAddress' => $email,
'ListID' => '348377'
),
'ProfileUpdateType' => 'Overwrite',
'ExternalEventIDs' => '12182',
'OverrideUnsubscribe' => true
);
Mage::log($params, null, 'mylogfile.log');
try {
$rest = $soapClient->SetContact($params);
} catch (SoapFault $e) {
echo '<pre>';
print($e->getMessage());
echo '</pre>';
}
$listtracksend = true;
return $this;
}
else if ($action == 'subscribe' and in_array($sites, array('airfacts', 'ipad', 'learntofly'))) {
$url = "http://example.com/" . $site . "/?na=ajaxsub";
}
else if ($action == 'unsubscribe') {
$url = "/unsubscribe.php";
}
else {
return $this;
}
$fields = array(
'ne' => $email,
'site' => $site
);
$ch = curl_init($url);
if ($action == 'unsubscribe') {
$returntransfer = true;
} else {
$returntransfer = false;
}
$opts = array(
CURLOPT_POSTFIELDS => $fields,
CURLOPT_RETURNTRANSFER => $returntransfer
);
curl_setopt_array($ch, $opts);
curl_multi_add_handle($mh, $ch);
$curl_reference_array[] = $ch;
}
$active = null;
do {
$mrc = curl_multi_exec($mh, $active);
} while ($active > 0);
foreach ($curl_reference_array as $chref) {
$html = curl_multi_getcontent($chref);
$chu = curl_init($html);
$fields = array(
'ts' => time()
);
$opts = array(
CURLOPT_POSTFIELDS => $fields
);
curl_setopt_array($chu, $opts);
curl_exec($chu);
curl_close($chu);
curl_multi_remove_handle($mh, $chref);
}
curl_multi_close($mh);
return $this;
}
?>