无法使用HTML内容创建Evernote Note

时间:2016-08-08 22:25:49

标签: php evernote

我无法通过API在Evernote中创建格式化的笔记。如果我运行以下PHP代码,我会收到错误:

$sandbox = true;
$key = "erersdfrtgsrttsdtgsr-3176";
$secret = "ejfiojsdfsdjfüjüsfjsdjfjsdfjüsefe";
$callback = "https://subdomain.saschak.ch/file.php";

$oauth_handler = new \Evernote\Auth\OauthHandler($sandbox);
$oauth_data  = $oauth_handler->authorize($key, $secret, $callback);
$token = $oauth_data["oauth_token"];
$client = new \Evernote\Client($token, $sandbox, null, null, FALSE);

$note = new \Evernote\Model\Note();
$note->title = htmlspecialchars($item["location_name"])." (".$item["image_likes"].")";
$note->content = new \Evernote\Model\PlainTextNoteContent("<a href=\"http://google.ch\">Test</a><br>Line two.");
$note->tagNames = array();
$notebook = null;
$client->uploadNote($note, $notebook);

之后我收到PHP错误。

如果我将字符串更改为以下或普通单词,那么它的工作原理如下:     $ note-&gt; content = new \ Evernote \ Model \ PlainTextNoteContent(“http://google.ch \”&gt; Test“);

我知道ENML语言,但在字符串中使用此语法我无法上传注释。

如何上传格式化的备注(HTML或ENML)。

1 个答案:

答案 0 :(得分:2)

尝试使用Evernote\Model\EnmlNoteContentEvernote\Model\HtmlNoteContent

像:

$note->content = new \Evernote\Model\EnmlNoteContent(
    "<a href=\"http://google.ch\">Test</a><br>Line two."
);

PlainTextNoteContent就是它所说的:纯文本。它不会允许标签。

ENML注释允许<a><br>标记