evernote PHP SDK不适用于免费帐户

时间:2017-03-16 16:59:47

标签: php sdk evernote

我已经从Github集成了PHP SDK:https://github.com/evernote/evernote-cloud-sdk-php

我已设法使用开发人员令牌连接高级帐户。这是一种享受。

但是,当我尝试访问更多帐户时,出现错误。这是我的代码

<pre>
require_once '../libs/evernote/src/autoload.php';
require_once('../libs/mysql.class.php');
require_once('../libs/debug.php');
require_once('../libs/functions.php');

session_start();
//Siren is the search term
$gMysql = new MySQL_Class(array("host"=>"localhost","user"=>"horscote","password"=>"feO@6i77","dbname"=>"horscote"));
$gMysql->connect();


$siren = $_POST['id'];

//if logged user - saved as viewed
$sqlViewed = 'SELECT evernoteSync FROM company WHERE SIREN='.$siren;
$isSync = $gMysql->queryValue($sqlViewed);
$gMysql->close();

if($isSync==1)
{
    $gMysql->connect();
    //get all admin evernotes
    $evernotes = $gMysql->queryList('SELECT * FROM evernote_users e inner join   users u on u.id=e.userid WHERE evernote=1 ORDER BY e.ID');


    $maintable = '';
    foreach($evernotes as $evernote)
    {
        //var_dump($evernote);

        $token = $evernote['token'];

        $sandbox = false;
        $china   = false;

        $client = new \Evernote\Client($token, $sandbox, null, null, $china);

        $search = new \Evernote\Model\Search($siren);

        $notebook = new \Evernote\Model\Notebook();

        //$notebook->guid = $evernote['notebook_guid'];

        //$scope = \Evernote\Client::SEARCH_SCOPE_ALL;

        //$order = \Evernote\Client::SORT_ORDER_REVERSE | \Evernote\Client::SORT_ORDER_RECENTLY_CREATED;

        //var_dump($notebook);
        $maxResult = 5;

        $results = $client->findNotesWithSearch($search, $notebook, $scope, $order, $maxResult);

        //var_dump($results);

        $table = '<div class="panel-group" id="accordionEvernote" role="tablist" aria-multiselectable="true" style="margin-top:10px">';
        $i=0;
        foreach ($results as $result) {
            $noteGuid    = $result->guid;
            $note = $client->getNote($noteGuid);

            $in = '';
            if($i==0)
            {
                $in = ' in';
                $plusMinus = '<i class="more-less fa fa-chevron-right"></i>';
            }
            else
            {
                $plusMinus = '<i class="more-less fa fa-chevron-right"></i>';
            }

            $advancedClient = new \Evernote\AdvancedClient($token, $sandbox);
            $noteStore = $advancedClient->getNoteStore();
            $userStore = $advancedClient->getUserStore();
            $userInfo = $userStore->getPublicUserInfo($evernote['username']);

            $completeNote = $noteStore->getNote($token,$noteGuid,TRUE,TRUE,TRUE,TRUE);
            $resources = $completeNote->resources;
            $sResources = '';
            foreach($resources as $res)
            {
                $resource = $noteStore->getResource($token, $res->guid, true, true, true, true);        
                $fileContent = $res->data->body;  
                $fileType = $res->mime;  
                $fileName = $res->attributes->filename;

                $resGuid = $res->guid; // example GUID
                $resUrl = $userInfo->webApiUrlPrefix . 'res/' . $resGuid;

                $attribute = $noteStore->getResourceAttributes($token, $res->guid);  

                $fileName = $attribute->fileName;
                $sResources .= '
                <div class="col-xs-10 col-sm-4 col-md-2">
              <div class="thumbnail" style="text-align:center">
                <i class="fa fa-file-text" aria-hidden="true" style="font-size:40px;color:#F05F40"></i>
                  <div class="caption">
                    <a tatget="_blank" href="'.$resUrl.'" style="font-size:10px">'.$fileName.'</a>
                </div>
              </div>
            </div>';
            }

            $tags = $noteStore->getNoteTagNames($token,$noteGuid);

            $created = date('d/m/Y',$completeNote->created/1000); 
            $updated = date('d/m/Y',$completeNote->updated/1000); 

            $hashTags = '';        
            foreach($tags as $tag)
            {
                $hashTags .='<span class="label label-primary" style="margin-right:5px"> <i class="fa fa-tag" aria-hidden="true"></i> '.$tag.'</span>';
            }

            $table .='<div class="panel panel-default">
                <div class="panel-heading" role="tab" id="heading'.$note->guid.'">
                    <h4 class="panel-title" style="font-size:12px">
                        <a role="button" data-toggle="collapse" data-parent="#accordionEvernote" href="#collapse'.$note->guid.'" aria-expanded="true" aria-controls="collapse'.$note->guid.'">

                            '.$plusMinus.'
                            '.$note->title.' - Crée le '.$created.' par '.$evernote['firstName'].' - Modifié le '.$updated.'</i>
                        </a>
                    </h4>
                </div>
                <div id="collapse'.$note->guid.'" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading'.$note->guid.'">
                    <div class="panel-body">
                          <div id="ntD'.$note->guid.'">  
                          <div style="margin-bottom:10px">'.$hashTags.'</div>
                          <div style="margin-bottom:10px" id="resources" class="row">'.$sResources.'</div>
                          '.$note->content.'
                          </div>
                    </div>
                </div>
            </div>';


            $i++;
        }
        $maintable .=$table;
    }

    $gMysql->close();

    if(isset($noteGuid) && !empty($noteGuid))
    {

        echo '<div style="text-align:justify">'.$maintable.'</div>';
    }
    else
    {
        $table = 'Aucune note trouvée pour cette société.';
        echo $table;

    }
}
else
{
    $table = '<div style="text-align:center"><button class="btn btn-success btn-lg" onclick="sync('.$siren.')"> Syncroniser</button></div>';
    echo $table;
}
</pre>

是否所有帐户都需要保费?高级帐户有效但其他帐户则无效。

0 个答案:

没有答案