1

我正在尝试开发一个脚本(使用 PHP 示例应用程序作为基础),它将根据 GET 值向 Evernote 发布一条笔记。

当我将它插入到functions.php的listNotebooks()的末尾时

$note_obj = new Note(array(
                'contents' => $note_contents,
                'title' => $title
                ));

它会引发 500 错误。(在我的代码中,之前定义了 $title 和 $note_contents。我花了很多时间试图为 PHP API 找到合适的文档,但它似乎不存在。任何关于这个主题的信息将不胜感激

更新:我没有意识到 API 正在使用 PHP 命名空间:这解决了问题:

//import Note class
use EDAM\Types\Note;
use EDAM\Types\NoteAttributes;
use EDAM\NoteStore\NoteStoreClient;

我添加注释的代码仍然不起作用,但是一旦我弄清楚了,我会在这里发布。

4

1 回答 1

2

需要导入这些类:

//import Note class
use EDAM\Types\Note;
use EDAM\Types\NoteAttributes;
use EDAM\NoteStore\NoteStoreClient;

这将定义我们的新注释:

       $noteAttr = new NoteAttributes();
                $noteAttr->sourceURL = "http://www.example.com";
                $note = new Note();
                $note->guid = null;
                $note->title = "My Title";
                $note->content = '<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml.dtd"><en-note>My Content</en-note>';
                $note->contentHash = null;
                $note->contentLength = null;
                $note->created = time()*1000;
                $note->updated = time()*1000;
                $note->deleted = null;
                $note->active = null;
                $note->updateSequenceNum = null;
                $note->notebookGuid = null;
                $note->tagGuids = null;
                $note->resources = null;
                $note->attributes = $noteAttr;
                $note->tagNames = null;
                addNote($note);

此函数将添加一个新注释:

function addNote($newnote) {
    global $noteRet;
    if (empty($noteRet)) {
        define("noteStoreHost", "sandbox.evernote.com");
define("noteStorePort", "80");
define("noteStoreProto", "https");
define("noteStoreUrl", "edam/note/");
            $noteStoreTrans = new THttpClient(noteStoreHost, noteStorePort, noteStoreUrl . $_SESSION['shardId'], noteStoreProto);
            $noteStoreProt = new TBinaryProtocol($noteStoreTrans);
            $noteStore = new NoteStoreClient($noteStoreProt, $noteStoreProt);
            $noteRet = $noteStore->createNote($_SESSION['accessToken'], $newnote);

    return $noteRet;
}
}
于 2013-05-22T17:06:17.047 回答