I'm trying to create a new Business Notebook
over PHP but I'm having no luck.
I've tried following this documentation and adapting the code to what is available to me using the Thrift module: NoteStore.
From my understanding of how the flow is meant to be, it's; create a new notebook, using the returned notebook get its shareKey, shareID, and businessId, use that information to create a linked notebook in the business note store.
I first tried to creating a new notebook using the non business note store, however the new notebook returned did not contain a shareKey, or any other information needed for creating a linked notebook. Instead I found creating a new notebook using the business note store returned a new notebook with some of this the required information under the 'sharedNotebooks' feild however the businessNotebook parameter was null, and there was no shareId within sharedNotebooks. And even though this new notebook is returned successfull, it is not visable in my personal or business accounts.
The returned notebook looks like
{
"guid": "d341cd12-9f98-XXX-XXX-XXX",
"name": "Hello World",
"updateSequenceNum": 35838,
"defaultNotebook": false,
"serviceCreated": 1478570056000,
"serviceUpdated": 1478570056000,
"publishing": null,
"published": null,
"stack": null,
"sharedNotebookIds": [603053],
"sharedNotebooks": [{
"id": 603053,
"userId": 40561553,
"notebookGuid": "d341cd12-9f98-XXX-XXX-XXX",
"email": "jack@businessEvernoteAccountEmail",
"notebookModifiable": true,
"requireLogin": null,
"serviceCreated": 1478570056000,
"serviceUpdated": 1478570056000,
"shareKey": "933ad-xxx",
"username": "xxx",
"privilege": 5,
"allowPreview": null,
"recipientSettings": {
"reminderNotifyEmail": null,
"reminderNotifyInApp": null
}
}],
"businessNotebook": null,
"contact": {
"id": 111858676,
"username": "XXX",
"email": "jack@personalEvernoteAccountEmail",
"name": "Jack XXXX",
"timezone": null,
"privilege": null,
"created": null,
"updated": null,
"deleted": null,
"active": true,
"shardId": null,
"attributes": null,
"accounting": null,
"premiumInfo": null,
"businessUserInfo": null
},
"restrictions": {
"noReadNotes": null,
"noCreateNotes": null,
"noUpdateNotes": null,
"noExpungeNotes": true,
"noShareNotes": null,
"noEmailNotes": true,
"noSendMessageToRecipients": null,
"noUpdateNotebook": null,
"noExpungeNotebook": true,
"noSetDefaultNotebook": true,
"noSetNotebookStack": true,
"noPublishToPublic": true,
"noPublishToBusinessLibrary": null,
"noCreateTags": null,
"noUpdateTags": true,
"noExpungeTags": true,
"noSetParentTag": true,
"noCreateSharedNotebooks": null,
"updateWhichSharedNotebookRestrictions": null,
"expungeWhichSharedNotebookRestrictions": null
}
}
Thus far, my code flow is as follows //Try catches left out for sortness
//Check if business user
$ourUser = $this->userStore->getUser($authToken);
if(!isset($ourUser->accounting->businessId)){
$returnObject->status = 400;
$returnObject->message = 'Not a buisness user';
return $returnObject;
}
// authenticateToBusiness and get business token
$bAuthResult = $this->userStore->authenticateToBusiness($authToken);
$bAuthToken = $bAuthResult->authenticationToken;
//Create client and set up business note store
$client = new \Evernote\AdvancedClient($authToken, false);
$bNoteStore = $client->getBusinessNoteStore();
//Create a new notebook in business note store- example result is json above
$newNotebook = new Notebook();
$newNotebook->name = $title;
$newNotebook = $bNoteStore->createNotebook($bAuthToken, $newNotebook);
//Look at new notebook and get information needed to create linked notebook
$sharedNotebooks = $newNotebook->sharedNotebooks[0];
$newLinkedNotebook = new LinkedNotebook();
$newLinkedNotebook->shareName = $title;
$newLinkedNotebook->shareKey = $sharedNotebooks->shareKey;
$newLinkedNotebook->username = $sharedNotebooks->username;
//$newLinkedNotebook->shardId = $sharedNotebooks->shardId; //isnt there
//This is where I think the trouble is happening ???
$newLinkedNotebook = $bNoteStore->createLinkedNotebook($bAuthToken, $newLinkedNotebook);
//Trying with business token throws
//{"errorCode":3,"parameter":"authenticationToken"}
//Even though within Evernote itself, I can add notebooks to this business
//Alternatively trying with the regular $authToken i receive
//{"errorCode":12,"message":"s570","rateLimitDuration":null}
// error code 12 being SHARD_UNAVAILABLE
//and trying on the regular noteStore
$newLinkedNotebook = $noteStore->createLinkedNotebook($authToken, $newLinkedNotebook);
//returns {"errorCode":5,"parameter":"LinkedNotebook.shardId"}