コード例 #1
0
 public function unsubscribeAction()
 {
     $status = array();
     $error = array();
     $token = $this->params()->fromRoute('id');
     if ($token != "" && strlen($token) == 44) {
         $model = new Common();
         $id = $model->getDecode($token);
         if ($id != "" && is_numeric($id)) {
             $api = new Api();
             $api_url = $this->getServiceLocator()->get('config')['api_url']['value'];
             $newsletter_res = $api->curl($api_url . "/api/newslettersubscription/" . $id . "/", array("status_id" => 0), "PUT");
             if ($newsletter_res->getStatusCode() == 200) {
                 $status = array('status' => 1, 'msg' => 'Your Email is sucessfully unsubscribe for newsletter..!!');
             } else {
                 $status = array('status' => 0, 'err' => "Sorry!!..Unsubscribe link is broken. Unable to process your request please try again.");
             }
         } else {
             $status = array('status' => 0, 'err' => "Sorry!!..Unsubscribe link is broken. Unable to process your request please try again.");
         }
     } else {
         return $this->redirect()->toUrl('/contact');
     }
     return new ViewModel(array('status' => $status));
 }