Closed ekdevdes closed 12 years ago
Hi Ethan,
Yes, I'm in fact using it with codeigniter2.
It's very easy, just put the library in your libraries directory and use it in your controllers with the following sample code :
class Notifications extends CI_controller {
function inbound()
{
include(APPPATH.'libraries/postmark_inbound.php');
$inbound = New PostmarkInbound(file_get_contents('php://input'));
//code store $inbound->subject() in the DB for example
}
}
So in postmark administration you can now give this url : http://myapp.com/notifications/inbound
Thanks!
when i use that code postmark is getting a 500 internal server error
Provide full contrôler code plz and watch tour php error log plz
Theres nothing in my error logs. why isn't this working? Oh please note the other actions are for other things
<?php
class Cron extends CI_Controller {
function __construct(){
parent::__construct();
$this->load->helper(array('rel_date','date'));
$this->load->model('site_model','site');
}
function send(){
$this->site->get_related_media_for_sponsors();
echo "everyone successfully received their emails";
}
function news(){
//$this->site->send_the_newsletter($_POST['plain']);
//$this->db->insert('children',array('first_name' => $_POST['plain']));
$this->site->send_the_newsletter($_POST['plain']);
}
function postmark(){
include(APPPATH.'libraries/postmark_inbound.php');
$inbound = New PostmarkInbound(file_get_contents('php://input'));
}
}
ok, I see the problem, in fact it raises an exception because you are directly accessing the controller but you don't provide any json, if you use a code like the following you will see the exception :
<?php
class Cron extends CI_Controller {
function __construct(){
parent::__construct();
}
function postmark(){
include(APPPATH.'libraries/postmark_inbound.php');
try {
$inbound = New PostmarkInbound(file_get_contents('php://input'));
}
catch (Exception $e) {
echo $e->getMessage();
}
}
}
This library is designed to get the content of a page where postmark send the json, if you want to test it locally use the json in the fixtures directory.
How do i use it with codeIgniter 2? As a helper or a hook?