I have problem, when I create MS team and channels using the MS Graph API, the channels are always hidden and users have to manually click show.
This is the request code to create MS team and two channels:
$data = [
'displayName' => 'Test MS Team',
"template#odata.bind" => "https://graph.microsoft.com/v1.0/teamsTemplates('standard')",
'description' => 'Created using MS Graph API v1',
'channels' => [
[
'displayName' => 'Test channel 1',
'isFavoriteByDefault' => true,
'description' => 'Test channel 1 descriptions'
],
[
'displayName' => 'Test channel 2',
'isFavoriteByDefault' => true,
'description' => 'Test channel 2 descriptions'
]
],
// Adding more than one member is currently not supported on MS graph
'members' => [
[
'#odata.type' => '#microsoft.graph.aadUserConversationMember',
'roles' => ['owner'],
'user#odata.bind' => "https://graph.microsoft.com/v1.0/users('{$this->me()->getId()}')"
],
]
];
$this->request('POST', '/teams', $data, [], true);
MS Graph docs: Create a team with multiple channels, installed apps, and pinned tabs using delegated permissions
And this is the results:
Channels are hidden
This feature is controlled by
isFavoriteByDefault
attribute on the channel, looks like this feature is currently not working and MS has created a bug for it please have a look over here
Related
How to create an event in a "Group Calendar" using the MS Graph APIs?
This is only possible using delegated permission from a Work or School Account.
Would you please share the code to achieve that (using the PHP - new Graph())?
Is it possible to do it completely silently, or login or consent pop-ups are involved?
HideAndSeek says he did it in the post: Microsoft Graph API: Group Calendar Events created by API are not sent to users Calendar but he does not share the code or explained how he did it.
Thanks
To use APIs that only support delegated permissions, authentication + user consent is required. Below is a code sample assuming the access token variable is acquired with delegated permissions. I am using MS Graph PHP SDK
$accessToken = 'eyJ0...';
$graph = new Graph();
$graph->setAccessToken($accessToken);
$attendees = [];
array_push($attendees, [
'emailAddress' => [
'address' => 'user#domain.com',
'name' => 'Name'
],
'type' => 'required'
]);
$newEvent = [
'subject' => 'Sample Event Subject',
'attendees' => $attendees,
'start' => [
'dateTime' => '2021-05-12T22:00:00',
'timeZone' => 'Pacific Standard Time'
],
'end' => [
'dateTime' => '2021-05-12T23:00:00',
'timeZone' => 'Pacific Standard Time'
],
'body' => [
"contentType" => "HTML",
"content" => "Chat about new hire"
]
];
$response = $graph->createRequest('POST', '/groups/group-id/calendar/events')
->attachBody($newEvent)
->setReturnType(Model\Event::class)
->execute();
echo "Created event - {$response->getSubject()}.";
Here is a complete example that will help you get started. The Guide is here
is it possible to do realtime voice call using nexmo/vonage with PHP or Javascript via web browser?
i used library called nexmo/laravel.
This sample code that i used:
$nexmo = Nexmo::calls()->create([
'to' => [[
'type' => 'phone',
'number' => '855969818674'
]],
'from' => [
'type' => 'phone',
'number' => '63282711511'
],
'answer_url' => ['https://gist.githubusercontent.com/jazz7381/d245a8f54ed318ac2cb68152929ec118/raw/6a63a20d7b1b288a84830800ab1813ebb7bac70c/ncco.json'],
'event_url' => [backpack_url('call/event')]
]);
with that code i can send text-to-speech, but how can i do realtime voice conversation person to person?
From the code you shared above, it looks like you might not have instantiated a client instance of the Nexmo PHP SDK, which is necessary to do so. You make an outbound call with an instantiated and authenticated client.
For example, first instantiate a client with the following, supplying the file path to your private key file, your application ID, your API key and your API secret. You can obtain all of those from the Dashboard
$basic = new \Nexmo\Client\Credentials\Basic('key', 'secret');
$keypair = new \Nexmo\Client\Credentials\Keypair(
file_get_contents((NEXMO_APPLICATION_PRIVATE_KEY_PATH),
NEXMO_APPLICATION_ID
);
$client = new \Nexmo\Client(new \Nexmo\Client\Credentials\Container($basic, $keypair));
Then, once you have a credentialed client, you can then invoke the $client->calls() methods on it. For example:
$client->calls()->create([
'to' => [[
'type' => 'phone',
'number' => '14843331234'
]],
'from' => [
'type' => 'phone',
'number' => '14843335555'
],
'answer_url' => ['https://example.com/answer'],
'event_url' => ['https://example.com/event'],
]);
You can find more information on using the PHP SDK on GitHub. You can also find code snippets, tutorials, and more instructions on our developer portal.
In the documentation of DataStore this example is mentioned:
$task = $datastore->entity('Task', [
'category' => 'Personal',
'done' => false,
'priority' => 4,
'description' => 'Learn Cloud Datastore'
]);
$datastore->insert($task);
I would like to get the key of this new entity that has just been inserted.
You may use a statement similar to: {const taskKey = datastore.key('Task');}
More detail is to be found in the Retrieving an entity sub-chapter.
I'm trying to create private channels on Discord using Restcord, a PHP library that is very closely mapped to the Discord API.
Currently, I have managed to create voice channels, but all users on the server are able to see and join the channels. How can I make the channels so they are only available when invited ?
My current test code is :
$discord = new \RestCord\DiscordClient(['token' => config('services.discord.bot_token')]);
$channel = $discord->guild->createGuildChannel([
'guild.id' => config('services.discord.guild_id'),
'name' => 'lobby_' . uniqid(),
'type' => 2, // Voice
'permission_overwrites' => [
],
]);
$invitation = $discord->channel->createChannelInvite([
'channel.id' => $channel->id,
]);
return "https://discordapp.com/invite/{$invitation->code}";
Thanks in advance, any help is much appreciated, either with Restcord or directly using the API.
You need to use the permission_overwrites field. This fields accepts arrays of the overwrite object kind.
Example:
$discord = new \RestCord\DiscordClient(['token' => <token>]);
$channel = $discord->guild->createGuildChannel([
'guild.id' => config(<your guild ID>),
'name' => '<channel name>',
'type' => 2, // Voice
'permission_overwrites' => [
'id' => <role OR user id>,
'type' => 'role' (if id is role) OR 'user' (if id is single user),
'allow' => <permission ID for allowed permissions>,
'deny' => <permissions ID for denied permissions>
]
]);
Note that if you'd leave "allow" and "deny" as 0 (default value), the role/user with id 'id' would have the same permissions as otherwise defined server-wide. To get the permissions ID for a certain set of permissions, use a Discord Permission Calculator like this one (here the ID is called permission number).
Hope it helps!
I'm an getting a list of files in a folder. The response contains a iconLink for every file returned. This icon is 16x16 pixels.
Does anyone know a way to retrieve a retina image? Or another way to retrieve a bigger icon image?
https://developers.google.com/drive/v2/reference/files
top: Google Drive UI
bottom: Google Drive API integration
The good news is although not officailly documented driver does have 2x resolution icons. The bad news is they have inconsistent file names; for example the icon you linked in the comments has a 32px version availabel here: ssl.gstatic.com/docs/doclist/images/mediatype/icon_3_pdf_x32.png
Now here is my soltion, it's not perfect but it will do the job for a while:
function getIcons($file_type)
{
$icons = [
'pdf' => [
'icon' => 'icon_12_pdf_list.png',
'retina' => 'icon_3_pdf_x32.png'
],
'document' => [
'icon' => 'icon_1_document_x16.png',
'retina' => 'icon_1_document_x32.png'
],
'image' => [
'icon' => 'con_1_image_x16.png',
'retina' => 'icon_1_image_x32.png'
],
'word' => [
'icon' => 'icon_1_word_x16.png',
'retina' => 'icon_1_word_x32.png'
],
'text' => [
'icon' => 'icon_1_text_x16.png',
'retina' => 'icon_1_text_x32.png'
],
'spreadsheet' => [
'icon' => 'icon_1_spreadsheet_x16.png',
'retina' => 'icon_1_spreadsheet_x32.png'
],
'form' => [
'icon' => 'icon_2_form_x16.png',
'retina' => 'icon_2_form_x32.png'
],
'audio' => [
'icon' => 'icon_1_audio_x16.png',
'retina' => 'icon_1_audio_x32.png'
]
];
return isset($icons[$file_type]) ? $icons[$file_type] : $icons['text'];
}
The reasion I say it will work for a while is that I'm asuming the _3_ in pdf icon file name for instance is the version number. So if Google updates it's icons again in the future this solution may brake.
I'm using drive rest api and what i observed was that iconLink attribute had a definite pattern.
"https://drive-thirdparty.googleusercontent.com/" + size + mimetype
By default size is 16. So, before adding your icon to Image, use this:
String iconLink = (String) jsonObject.get("iconLink");
iconLink=iconLink.replace("16","128");
check out these both links:
https://drive-thirdparty.googleusercontent.com/128/type/application/pdf
https://drive-thirdparty.googleusercontent.com/16/type/application/pdf
Looks like images with x128 also added/present for various versions:
Ver. 1
Ver. 2
Ver. 3
Better to replace the x16 from the fetched iconLink and replace it with x128.