Created
April 25, 2022 19:24
-
-
Save schube/0ae7b21177c3226e1adfd5776ad09f36 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| header("Content-Type: application/json"); | |
| $data=array(); | |
| $data['success']=false; | |
| try { | |
| $fm = new \FileMaker ( \Schubec\Config\FmApiConfig::DATABASE, \Schubec\Config\FmApiConfig::URL, \Schubec\Config\FmApiConfig::USERNAME, \Schubec\Config\FmApiConfig::PASSWORD ); | |
| $command = $fm->newAddCommand ( 'www_NewsletterTracking' ); | |
| $command->setField('id', $json['id']); | |
| $command->setField('camp_id', $json['camp_id']); | |
| $command->setField('campaign name', $json['campaign name']); | |
| $command->setFieldFromTimestamp('date_sent', $json['ts_sent']); | |
| $command->setFieldFromTimestamp('date_event', $json['ts_event']); | |
| $command->setField('event', $json['event']); | |
| $command->setField('tag', $json['tag']); | |
| $command->setField('email', $json['email']); | |
| $fmresult = $command->execute (); | |
| if (\FileMaker::isError ( $fmresult )) { | |
| throw new \Exception("FM Exception: ".$fmresult->getMessage (), $fmresult->getCode); | |
| } | |
| $data['success']=true; | |
| http_response_code(200); | |
| } catch (\Exception $e) { | |
| http_response_code(500); | |
| $data['error']['code']=$e->getCode(); | |
| $data['error']['text']=$e->getMessage(); | |
| } | |
| echo json_encode($data); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment