How to get Conversation ID?
This is not an issue, but I need help.
After calling:
$conversations = $client->conversations()->list($filters); echo json_encode($conversations);
All I get was:
{"0":{}}
How do I get the conversation ID?
👋 It looks like the $filters aren't matching any conversations which is the result set is empty. You can adjust your filters to provide some Conversations provided there are some within the mailbox you're working with. Once you're seeing conversations there, you can follow this example for how to access the results.
I removed all possible filters, as below:
<?php
require __DIR__ . '/vendor/autoload.php';
require '_credentials.php';
use HelpScout\Api\ApiClientFactory;
use HelpScout\Api\Conversations\Conversation;
use HelpScout\Api\Conversations\ConversationFilters;
use HelpScout\Api\Conversations\ConversationRequest;
use HelpScout\Api\Conversations\CustomField;
use HelpScout\Api\Conversations\Threads\ChatThread;
use HelpScout\Api\Conversations\Threads\PhoneThread;
use HelpScout\Api\Tags\Tag;
use HelpScout\Api\Customers\Customer;
use HelpScout\Api\Entity\Collection;
//Creating Client Object
$client = ApiClientFactory::createClient();
$client = $client->useClientCredentials(APP_ID, APP_SECRET);
// List conversations
$conversations = $client->conversations()
->list()
->getFirstPage()
->toArray();
$filters = (new ConversationFilters())
->inMailbox(8089)
->inStatus('all')
->sortField('createdAt')
->sortOrder('asc');
$conversations = $client->conversations()->list($filters);
echo json_encode($conversations);
?>
And it returned this:
{"0":{},"1":{},"2":{},"3":{},"4":{},"5":{},"6":{},"7":{},"8":{},"9":{},"10":{},"11":{},"12":{},"13":{},"14":{},"15":{},"16":{},"17":{},"18":{},"19":{},"20":{},"21":{},"22":{},"23":{},"24":{}}
Can't figure what I did wrong... will appreciate some/any help.
I think it's querying the results successfully, which is why it's showing there's 24 empty objects in that last comment. All of the properties on Conversation are private which is why I think it's coming through as an empty object in the output. I suspect if you iterated over them and echoed the data, you'd be able to access the data you're looking for.
foreach ($conversations as $conversation) {
echo $conversation->getId().PHP_EOL;
}
Closing this issue due to inactivity. Please feel free to reopen if needed!