コード例 #1
0
$r = $contextIO->listMessages($accountId, $args);
foreach ($r->getData() as $message) {
    echo "Subject: " . $message['subject'] . "\n";
}
// EXAMPLE 2
// Download all versions of the last 2 attachments exchanged with bill@widgets.com
$saveToDir = dirname(__FILE__) . "/" . mt_rand(100, 999);
mkdir($saveToDir);
$args = array('email' => '*****@*****.**', 'limit' => 2);
echo "\nObtaining list of last two attachments exchanged with {$args['email']}\n";
$r = $contextIO->listFiles($accountId, $args);
foreach ($r->getData() as $document) {
    echo "\nDownloading all versions of document \"" . $document['file_name'] . "\"\n";
    foreach ($document['occurrences'] as $attachment) {
        echo "Downloading attachment '" . $attachment['file_name'] . "' to {$saveToDir} ... ";
        $contextIO->getFileContent($accountId, array('file_id' => $attachment['fileId']), $saveToDir . "/" . $attachment['file_name']);
        echo "done\n";
    }
}
// EXAMPLE 3
// Download all attachments with a file name that contains the word 'proposal'
$saveToDir = dirname(__FILE__) . "/" . mt_rand(100, 999);
mkdir($saveToDir);
echo "\nDownloading all attachments matching 'creenshot'\n";
$args = array('file_name' => 'creenshot');
$r = $contextIO->listFiles($accountId, $args);
foreach ($r->getData() as $attachment) {
    echo "Downloading attachment '" . $attachment['file_name'] . "' to {$saveToDir} ... ";
    $contextIO->getFileContent($accountId, array('file_id' => $attachment['file_id']), $saveToDir . "/" . $attachment['file_name']);
    echo "done\n";
}