大家好,我是新来的。 我坚持使用 Magento API。我正在为我的电子商务网站创建 Magento API。我已经创建了所有 API,但对于忘记密码 API,我没有得到任何解决方案。我使用了默认的忘记密码控制器,但它没有向我发送包含更改密码链接的电子邮件,请检查我的代码,请帮助我设置此忘记密码 API。我还搜索了所有文档,但没有得到任何答案。我也发布了我的代码,所以请参考它并让我知道我哪里有错误。
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
$email = $_REQUEST['email'];
require_once ('../app/Mage.php');
Mage::app();
$customer = Mage::getModel('customer/customer')
->setWebsiteId(Mage::app()->getStore()->getWebsiteId())
->loadByEmail($email);
//print_r($customer);
if ($customer->getId()) {
try {
$newResetPasswordLinkToken = Mage::helper('customer')->generateResetPasswordLinkToken();
$customer->changeResetPasswordLinkToken($newResetPasswordLinkToken);
$customer->setStoreId(Mage::app()->getStore()->getId());
$customer->sendPasswordResetConfirmationEmail();
$response['response'] = "success";
$response['message']="Password Reset Link Has Been Sent to Your Email Please Check, Your Mail Box!";
echo json_encode($response);
} catch (Exception $exception) {
Mage::log($exception);
}
}else{
$response['response'] = "failed";
$response['message']="Please Enter a Valid Email!";
echo json_encode($response);
}
?>
最近我致力于忘记密码magento api,它工作正常,但唯一困难的是我发现我必须将忘记密码文件名保存到index.php。创建一个 api 文件夹并以 index.php 名称保存
<?php
if(!empty($_REQUEST['email']))
{
$yourCustomerEmail=$postcode = $_REQUEST['email'];
$customer = Mage::getModel('customer/customer')
->setWebsiteId(Mage::app()->getStore()->getWebsiteId())
->loadByEmail($yourCustomerEmail);
//echo $customer->getId();
if ($customer->getId()) {
try {
$newResetPasswordLinkToken = Mage::helper('customer')->generateResetPasswordLinkToken();
$customer->changeResetPasswordLinkToken($newResetPasswordLinkToken);
$customer->sendPasswordResetConfirmationEmail();
$result = array('action'=> 'send','statuscode'=> '200');
echo json_encode($result);
} catch (Exception $exception) {
//echo "Exception";
Mage::log($exception);
}
}
else
{
$result = array('action'=> 'failed','statuscode'=> '300');
echo json_encode($result);
}
}
else
{
$result = array('action'=> 'failed','statuscode'=> '300');
echo json_encode($result);
}
?>