1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| public function executeSendsms(sfWebRequest $request)
{
$this->forward404Unless($request->isMethod(sfRequest::POST));
$form = new SipSmsForm();
$this->sipline = SipLinePeer::getByUserId($this->getUser()->getId());
$form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
if ($form->isValid())
{
$Sipsms = $form->save();
$Sipsms->setDateEnvoi(date('Y-m-d'));
$Sipsms->setUserId($this->getUser()->getId());
$Sipsms->save();
try {
$soap = new SoapClient("https://www.ovh.com/soapi/soapi-re-1.12.wsdl",array("trace"=> 1,"exceptions"=>0));
$session = $soap->login("cb2850-ovh", "dAKoWvo1","fr", false);
$result = $soap->telephonySmsSend($session, "sms-cb2850-1", "+33".substr($this->sipline->getNumber(),1), $Sipsms->getNumEnvoi(), $Sipsms->getTextSms(), "", "", "", "", "", "");
$this->message = "telephonySmsSend successfull ". "+33".substr($this->sipline->getNumber(),1)." ".$Sipsms->getNumEnvoi()."\n";
$soap->logout($session);
$profile = sfGuardUserProfilePeer::getByID($this->getUser()->getId());
$profile->getSmsCredit();
var_dump($profile);
$profile = $profile - 1;
$profile->setSmsCredit($Profile);
$profile->Save();
}
catch(SoapFault $fault) {
echo $fault;
}
$this->redirect('account/Sms');
}
else
{
$this->form = $form;
$this->setTemplate('Infosms');
} |
Partager