我在使用Gmail PHP API时遇到问题.
我想检索电子邮件的正文内容,但我只能检索有附件的电子邮件!我的问题是为什么?
到目前为止,这是我的代码:
// Authentication things above...
$client = getClient();
$gmail = new Google_Service_Gmail($client);
$list = $gmail->users_messages->listUsersMessages('me', ['maxResults' => 1000]);
while ($list->getMessages() != null) {
foreach ($list->getMessages() as $mlist) {
$message_id = $mlist->id;
$optParamsGet2['format'] = 'full';
$single_message = $gmail->users_messages->get('me', $message_id, $optParamsGet2);
$threadId = $single_message->getThreadId();
$payload = $single_message->getPayload();
$headers = $payload->getHeaders();
$parts = $payload->getParts();
//print_r($parts); PRINTS SOMETHING ONLY IF I HAVE ATTACHMENTS...
$body = $parts[0]['body'];
$rawData = $body->data;
$sanitizedData = strtr($rawData,'-_', '+/');
$decodedMessage = base64_decode($sanitizedData); //should display my body …Run Code Online (Sandbox Code Playgroud) 在Angular2中将字符串强制转换为JSON的正确语法是什么?我试过了:
var someString;
someString.toJSON(); //or someString.toJson();
Run Code Online (Sandbox Code Playgroud)
它说: someString.toJSON is not a function
我迷路了,因为它与Angular1合作.
如果我尝试直接在我的字符串上添加一个属性(格式化为真正的JSON):
var someString;
someString.att = 'test';
Run Code Online (Sandbox Code Playgroud)
它说: TypeError: Cannot create property 'att' on string '...'
正如标题所示,我试图在LoopbackJs上的GeoPoints属性上添加一个2dsphere索引.我的MongoDB shell版本是3.2.3 - 所以应该这样做.
以下是我到目前为止的尝试:
在我的server/datasource.js中添加enableGeoIndexing
{
...
"myDs": {
"host": "localhost",
"port": 27017,
"database": "myDB",
"name": "myDs",
"connector": "mongodb",
"enableGeoIndexing": true
}
Run Code Online (Sandbox Code Playgroud)
...}
似乎没有任何改变.
使用Loopback方式添加索引+具有自动更新脚本:
{
"name": "NsUser",
"base": "User",
"idInjection": true,
"options": {
"validateUpsert": true
},
"indexes": {
"geopoint_index": {
"geopoint": "2dsphere"
}
},
"properties": {
"created": {
"type": "date"
},
"firstname": {
"type": "string"
},
"lastname": {
"type": "string"
},
"geopoint": {
"type": "geopoint"
},
...
}
…
}
我收到一个错误:
"ok" : 0,
"errmsg" : "Can't extract …Run Code Online (Sandbox Code Playgroud)