function rksnwp_sync_evernote()
{
global $rksnwp_path;
global $rksnwp_options;
$sdk_path = $rksnwp_path . "lib/";
require_once $sdk_path . 'autoload.php';
require_once $sdk_path . 'Evernote/Client.php';
require_once $sdk_path . 'packages/Errors/Errors_types.php';
require_once $sdk_path . 'packages/Types/Types_types.php';
require_once $sdk_path . 'packages/Limits/Limits_constants.php';
$authToken = $rksnwp_options['evernote']['auth_token'];
if ($authToken == "your developer token") {
print "Please fill in your developer token\n";
print "To get a developer token, visit https://www.evernote.com/api/DeveloperToken.action\n";
exit(1);
}
$client = new Client(array('token' => $authToken, 'sandbox' => false));
$userStore = $client->getUserStore();
$noteStore = $client->getNoteStore();
$search_words = apply_filters('sentinote_evernote_search_string', '');
// Search and retrieve notes
$search = new NoteFilter();
$search->words = $search_words;
$offset = 0;
$pageSize = 10;
$notes = null;
$guids = array();
// Evernote GUIDs
// Find and process each note
do {
$result = $noteStore->findNotes($search, $offset, $pageSize);
$notes = $result->notes;
if (is_array($notes)) {
if (count($notes) > 0) {
foreach ($notes as $note) {
// Keep track of read notes
array_push($guids, $note->guid);
// Note Args
$theNote = apply_filters('sentinote_process_en_note_data', array('guid' => $note->guid, 'title' => $note->title, 'updated' => $note->updated, 'created' => $note->created, 'tag_guids' => $note->tagGuids, 'resources' => $note->resources, 'resource_path' => array(), 'resource_url' => array(), 'resource_hash' => array(), 'latitude' => $note->attributes->latitude, 'longitude' => $note->attributes->longitude, 'altitude' => $note->attributes->altitude, 'author' => $note->attributes->author, 'tag_names' => array(), 'action' => 'none', 'content' => null, 'note_store' => $noteStore, 'wp_post' => null, 'wp_attachments' => array()));
do_action('sentinote_process_en_note', $theNote);
wp_reset_query();
// just to be safe
}
}
}
$offset = $offset + $pageSize;
} while ($result->totalNotes > $offset);
do_action('sentinote_evernote_remove_posts', $guids);
}