/**
  * Retrieves the contents of an IMMN message part.
  *
  * @method getMessageContent
  * 
  * @param {string} msgId The messageId of the message 
  * @param {string} partId The partNumber to retrieve
  *
  * @return {Response} Returns Response object
  * @throws ServiceException if API request was not successful.
  */
 public function getMessageContent($msgId, $partId)
 {
     $token = $this->getSessionConsentToken('MIM');
     $immnSrvc = new IMMNService($this->base_url, $token);
     $result = $immnSrvc->getMessageContent($msgId, $partId, true);
     http_response_code($result->getResponseCode());
     if ($result->getResponseCode() == 200) {
         header("Content-Type:" . $result->getHeader('content_type'));
         header("Content-Length:" . $result->getHeader('download_content_length'));
     }
     return $result->getResponseBody();
 }
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
session_start();
require_once __DIR__ . '/common.php';
require_once __DIR__ . '/../lib/IMMN/IMMNService.php';
use Att\Api\IMMN\IMMNService;
$arr = null;
try {
    envinit();
    $immnSrvc = new IMMNService(getFqdn(), getSessionToken());
    $msgId = $_POST['contentMsgId'];
    $partNumber = $_POST['contentPartNumber'];
    $content = $immnSrvc->getMessageContent($msgId, $partNumber);
    $arr = array('success' => true);
    $splitType = explode('/', $content->getContentType());
    $ctype = strtolower($splitType[0]);
    if ($ctype == 'text' || $ctype == 'plain') {
        $arr['text'] = 'Message Content: ' . $content->getContent();
    } else {
        if ($ctype == 'image') {
            $arr['image'] = array('type' => $content->getContentType(), 'base64' => base64_encode($content->getContent()));
        } else {
            if ($ctype == 'video') {
                $arr['video'] = array('type' => $content->getContentType(), 'base64' => base64_encode($content->getContent()));
            } else {
                if ($ctype == 'audio') {
                    $arr['audio'] = array('type' => $content->getContentType(), 'base64' => base64_encode($content->getContent()));
                }
 public function handleGetMsgContent()
 {
     $vnames = array('getMessageContent', 'messageId', 'partNumber');
     $this->copyToSession($vnames);
     if (!isset($_SESSION['getMessageContent'])) {
         return;
     }
     try {
         $msgId = $_SESSION['messageId'];
         $pNumber = $_SESSION['partNumber'];
         $immnSrvc = new IMMNService($this->apiFQDN, $this->getSessionToken());
         $this->clearSession(array('getMessageContent'));
         $content = $immnSrvc->getMessageContent($msgId, $pNumber);
         $this->results[C_GET_MSG_CONTENT] = $content;
     } catch (Exception $e) {
         $this->errors[C_GET_MSG_CONTENT] = $e->getMessage();
         $this->clearSession(array('getMessageContent'));
     }
 }
Example #4
0
    // Specify the id of the message to retrieve.
    $msgId = 'ENTER VALUE!';
    // Send the request to get the message.
    $msg = $immnSrvc->getMessage($msgId);
    echo "msgId: " . $msg->getMessageId() . "\n";
} catch (ServiceException $se) {
    echo $se->getErrorResponse();
}
/* This try/catch block tests the getMessageContent method. */
try {
    // Enter the id of the message.
    $msgId = 'ENTER VALUE!';
    // Enter the id of the content to retrieve.
    $partId = 'ENTER VALUE!';
    // Send the request to get the message content.
    $msgContent = $immnSrvc->getMessageContent($msgId, $partId);
} catch (ServiceException $se) {
    echo $se->getErrorResponse();
}
/* This try/catch block tests the getMessagesDelta method. */
try {
    // Enter message state.
    $state = 'ENTER VALUE!';
    // Send the request to get the delta of the messages.
    $msgsDelta = $immnSrvc->getMessagesDelta($state);
    echo "state: " . $msgsDelta->getState() . "\n";
} catch (ServiceException $se) {
    echo $se->getErrorResponse();
}
/* This try/catch block tests the updateMessages method. */
try {