-
Can you provide some guidance on how to set presence and subscribe for endpoints in Skype? I am currently facing issues where I'm unable to set presence and subscribe for endpoints after retrieving data from a file. When logging in, I can successfully set presence and use the endpoint for message polling. However, when I try to do the same after retrieving data from a file, I receive 400 or 404 error codes. Can you also explain how setting presence and subscribing for endpoints work in Skype? Function: configureEndpointThis function is used to configure the endpoint by allowing presence and subscribing to the endpoint. Parameters
Codepublic function configureEndpoint(Session $session): void
{
$this->allowPresence($session);
$this->subscribeEndpoint($session);
$this->subscribePresence($session);
} Function: allowPresenceThis function is used to allow the presence of the endpoint. Parameters
Codepublic function allowPresence(Session $session): void
{
$url = sprintf(
'%s/users/ME/endpoints/%s/presenceDocs/messagingService',
$session->getRegistrationToken()->getMessengerUrl(),
$session->getEndpoint()->getId()
);
$request = null;
try {
$request = $this->request('PUT', $url, [
'authorization_session' => $session,
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
],
'body' => json_encode([
'id' => 'messagingService',
'type' => 'EndpointPresenceDoc',
'selfLink' => 'uri',
'privateInfo' => [
'epname' => "phpSkype",
],
'publicInfo' => [
'capabilities' => '',
'type' => 1,
'skypeNameVersion' => 'skype.com',
'nodeInfo' => 'xx',
'version' => '908/1.30.0.128',
],
]),
]);
} catch (ClientException $e) {
$response = $e->getResponse();
$response->getStatusCode();
}
if ($request->getStatusCode() == 200) {
$result = json_decode($request->getContent(), true);
$session->getEndpoint()->setPresence(true);
$session->getEndpoint()->setName($result['privateInfo']['epname']);
$session->getEndpoint()->setPresenceInfo($result);
}
} Function: subscribeEndpointThis function is used to subscribe to the endpoint. Parameters
Codepublic function subscribeEndpoint(Session $session): void
{
$url = sprintf(
'%s/users/ME/endpoints/%s/subscriptions',
$session->getRegistrationToken()->getMessengerUrl(),
$session->getEndpoint()->getId()
);
$resources = [
'/v1/threads/ALL',
'/v1/users/ME/contacts/ALL',
'/v1/users/ME/conversations/ALL/messages',
'/v1/users/ME/conversations/ALL/properties'
];
$requestData = [
'interestedResources' => $resources,
'template' => 'raw',
'channelType' => 'httpLongPoll',
'conversationType' => 2047,
];
$response = $this->request('POST', $url, [
'authorization_session' => $session,
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
],
'body' => json_encode($requestData),
]);
if ($response->getStatusCode() == 201) {
$session->getEndpoint()->setSubscribed(true);
$session->getEndpoint()->setSubscribedUrl($response->getHeaders()['location'][0]);
}
} Function: subscribePresenceThis function is used to subscribe to presence. Parameters
Codepublic function subscribePresence(Session $session): void
{
$url = sprintf(
'%s/users/ME/endpoints/%s/subscriptions/0',
$session->getRegistrationToken()->getMessengerUrl(),
$session->getEndpoint()->getId()
);
$resources = [
'/v1/threads/ALL',
'/v1/users/ME/contacts/ALL',
'/v1/users/ME/conversations/ALL/messages',
'/v1/users/ME/conversations/ALL/properties'
];
$contacts = $this->loadAllContacts($session);
foreach ($contacts as $contact) {
$resources[] = '/v1/users/ME/contacts/'. $contact->getPersonId();
}
try {
$response = $this->request('PUT', $url, [
'authorization_session' => $session,
'query' =>
[
'name' => 'interestedResources',
],
'json' =>[
'interestedResources' => $resources,
]
]);
} catch (ClientException $e) {
$response = $e->getResponse();
$response->getStatusCode();
}
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
From a cursory look, this looks roughly the same as what SkPy's
You're going to need to elaborate on that -- what file, where, how? At a guess, that's taking a while and the endpoint has expired by the time you try to poll with it again. See note on Line 1038 in 8f4d493
(Again, this is all guesswork from Skype for Web.) You get a default endpoint called |
Beta Was this translation helpful? Give feedback.
As noted above, your endpoint will have expired by then if you're not constantly polling it or calling the keep-alive API. Just make a new endpoint and subscribe it again.
(It might be worth watching what Skype for Web does if you disconnect your computer for a few minutes. I assume mobile clients handle this differently so that they're not constantly churning on endpoints, but they may have completely separate APIs.)