We recently started using Flowdock at ZenRockers and wanted to send data from one of our php websites to the team inbox. It turned out to be a bit tricky to get it to post the data correctly.

Here is a simple PHP class for the Push API.

//
// Usage:
// Flowdock::TeamInbox('John Johnson', 'did something ...',
//						'<p>More detailed description ...</p>',
//						array('#hash', '#tag'));
//
class Flowdock
{
	public static $_URL	= 'https://api.flowdock.com/v1/messages/team_inbox/';
	public static $_TOKEN 	= 'api...token...here';
	public static $_SOURCE	= 'app name';
	public static $_EMAIL	= 'from@address.com';

	public static function TeamInbox($name, $subject, $content, $tags=array())
	{
		$data = array(
			'source' => Flowdock::$_SOURCE,
			'from_address' => Flowdock::$_EMAIL,
			'from_name' => $name,
			'subject' => $subject,
			'content' => $content,
			'tags' => $tags
		);
		$data_string = json_encode($data);

		$ch = curl_init(Flowdock::$_URL.Flowdock::$_TOKEN);
		curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
		curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($ch, CURLOPT_HTTPHEADER, array(
		    'Content-Type: application/json',
		    'Content-Length: ' . strlen($data_string))
		);
		$result = curl_exec($ch);
	}
}