我正在尝试获取属于某个对话的消息列表。
// Implements a dictionary's functionality
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <stdint.h>
#include <ctype.h>
#include "dictionary.h"
// Represents a node in a hash table
typedef struct node
{
char word[LENGTH + 1];
struct node *next;
}
node;
const unsigned int N = 4294967291;
unsigned int dictSize = 0;
// Hash table
node *table[N];
// Returns true if word is in dictionary else false
bool check(const char *word)
{
unsigned int hn = hash(word);
node *buffer = table[hn];
while(buffer!=NULL)
{
if(strcasecmp(word, buffer->word)==0)
{
return true;
}
else
{
buffer = buffer->next;
}
}
return false;
}
// Hashes word to a number
unsigned int hash(const char *word)
{
char x = tolower(word[0]);
return (int)x;
}
// Loads dictionary into memory, returning true if successful else false
bool load(const char *dictionary)
{
FILE *fp;
fp = fopen(dictionary, "r");
if(fp == NULL)
{
printf("Could not open file\n");
return false;
}
char word[LENGTH + 1];
int len;
unsigned int hn;
while(fscanf(fp, "%s", word) != EOF)
{
node *newNode = malloc(sizeof(node));
if (newNode == NULL)
{
printf("Could not create new node\n");
return false;
}
hn = hash(word);
if(hn > N || hn < 0)
{
printf("Hash function acted improperly");
return false;
}
strcpy(newNode->word, word);
newNode->next = NULL;
if(table[hn] == NULL)
{
table[hn] = newNode;
}
else
{
newNode->next = table[hn];
table[hn] = newNode;
}
dictSize++;
}
fclose(fp);
return true;
}
// Returns number of words in dictionary if loaded else 0 if not yet loaded
unsigned int size(void)
{
return dictSize;
}
// Unloads dictionary from memory, returning true if successful else false
bool unload(void)
{
for(unsigned int i = 0; i < N+1; i++)
{
node *next = table[i];
while(next!=NULL)
{
node *buffer = next;
next = next->next;
free(buffer);
}
free(next);
free(table[i]);
}
return true;
}
这给出了错误信息
<块引用>包含过滤器只能用于字符串属性。
我不明白这个错误信息,因为conversationId 是一个字符串。
从 this answer 转到另一个问题,我认为将 var conversationMessages = await client.Me.Messages
.Request()
.Filter($"startsWith(conversationId, '{message.ConversationId}')")
.Select(m => new { m.ConversationId })
.GetAsync().ConfigureAwait(false);
替换为 startsWith
或 equals
可能会起作用。这会更可取,因为我想检查它是否相等。但后来我得到了
无效的过滤器子句
暗示 eq
尚不受支持。
答案 0 :(得分:0)
我已经在 Graph Explore 中对其进行了测试,并且对我来说效果很好。我已经给出了 HTTP 调用 - https://graph.microsoft.com/v1.0/me/messages?$filter=conversationId eq 'AAQkAGI0Mjk2NTQ5LTE4MjctNDE1Yy04Nzc0LWIxNzA0MDBkNDkwZAAQADdMKw2knP9Pj1rq9BpHpsc='
所以试试下面的代码。
var conversationMessages = await client.Me.Messages
.Request()
.Filter("conversationId eq 'messageConverstaionid'")
.GetAsync();