/**
 * get message
 *
 * @param $list_id
 * @param $message_id
 * @return array
 */
function cw_vertical_response_get_message($list_id, $message_id)
{
    global $config;
    $vertical_response_email = trim($config[vertical_response_addon_name]['vertical_response_email']);
    $vertical_response_password = trim($config[vertical_response_addon_name]['vertical_response_password']);
    try {
        $vr = new SoapClient(vertical_response_wsdl, array('connection_timeout' => 5));
        $sid = $vr->login(array('username' => "{$vertical_response_email}", 'password' => "{$vertical_response_password}", 'session_duration_minutes' => vertical_response_ses_time));
        $params = array('session_id' => $sid, 'statuses' => array('active'), 'limit' => 20, 'include_content' => true, 'include_lists' => true);
        if ($message_id) {
            $params['campaign_ids'] = array($message_id);
        }
        $messages = $vr->enumerateEmailCampaigns($params);
        if (!empty($messages)) {
            $data = array();
            foreach ($messages as $message) {
                if ($message->lists && is_array($message->lists)) {
                    foreach ($message->lists as $list) {
                        if ($list->id == $list_id && $message->contents) {
                            $data['news_id'] = $message->id;
                            foreach ($message->contents as $content) {
                                if ($content->type == "subject") {
                                    $data['subject'] = $content->copy;
                                }
                                if ($content->type == "freeform_html") {
                                    $data['body'] = $content->copy;
                                }
                            }
                            return $data;
                        }
                    }
                }
            }
        }
    } catch (SoapFault $exception) {
        //exit ('fault: "' . $exception->faultcode . '" - ' . $exception->faultstring . "\n");
        return array();
    }
    return array();
}