Is it possible to set out user status message in teams through graph API? - powershell

I want to set user status message in teams using graph api and I saw this code but it's not working for me is there any solution that could help??
"#odata. context":"https://graph.mic.."
"id": "f599db41-7474-416a-acb1-88f9e
"availability": "Available"
"activity" :"Available"
"outofOfficeSettings": {"message": "oof mes"
"is0utofoffice":true }
Note: the availability & activity is working and has been updating in teams but the part below is not working for me""
or is there any way using graph api that I could set teams status message from bambooHR direct to teams?

You cannot set out of office user presence through graph API. As of now, only the parameters mentioned below are supported in the body of setPresence call
POST https://graph.microsoft.com/beta/users/object_id_of_user/presence/setPresence
Also, this call is supported under Application context only and not under user context.
sessionId
availability
activity
expirationDuration
However, you can view the out of office user presence via graph API by using below call:
GET https://graph.microsoft.com/beta/me/presence
or
GET https://graph.microsoft.com/beta/users/object_id_of_user/presence
{
"id": "fa8bf3dc-eca7-46b7-bad1-db199b62afc3",
"availability": "Available",
"activity": "Available",
"outOfOfficeSettings": {
"message": null,
"isOutOfOffice": false
}
}
Ref Doc:
https://learn.microsoft.com/en-us/graph/api/presence-get?view=graph-rest-beta&tabs=http
https://learn.microsoft.com/en-us/graph/api/presence-setpresence?view=graph-rest-beta&tabs=http
If you wish you may vote for this feature on Microsoft Teams ยท Community

Related

Facebook API Lead retrieval for internal business app should i submit for App Review

I am building a dedicated CRM solution and it is supposed to show the list of Facebook leads of the client and then convert manually it to internal lead . I am managed to setup a websocket client and Facebook is sending me lead details including leadgen_id.
{
"object":
"page" ,
"entry": [{
"id": "*****" ,
"time": 1627211279 ,
"changes": [{
"value": {
"form_id": "******" ,
"leadgen_id": "******" ,
"created_time": 1627211277 ,
"page_id": "******"} ,
"field": "leadgen"}
]}
]}
Then i have created an user access_token using Facebook's graph api and requested for the details of the leadgen_id using api endpoint
https://graph.facebook.com/v11.0/<LEADGEN_ID>?access_token=<ACCESS_TOKEN>
I was able to get the details of the test lead I created with the Facebook 's lead testing tool. But when accessing the production leadgen_id I am getting an exception with following as response.
{
"error": {
"message": "Unsupported get request. Object with ID '<LEADGEN_ID' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
"type": "GraphMethodException",
"code": 100,
"error_subcode": 33,
"fbtrace_id": "*********"
}
}
Then I have tried using a system user token and its not even working for the test leads. In some part of documentation it is saying that I need to complete App review to access live data using lead_retrieval and in some other part of documentation its quoted that I don't need app review to use API for internal users . And I don't get the point of creating a 'login with Facebook' for this internal app specific for one user .
Is there anyway other way than completing app review to access lead details using leadgen_id ?
Its turns out I need to complete the app review specifying it as a 'Server to server app' on the review description, which doesn't need any Login with facebook button . Got the idea from https://developers.facebook.com/docs/app-review/resources/sample-submissions/server-to-server/

Hot to create new channel in Teams that is not hidden, using GraphAPI

I have an app that uses microsoft's graphAPI to create channels in my organizations Team dynamically. All is well and I can create the channels, except the channels I'm creating are marked as hidden - users need to manually "show" the channel before reading messages or even get notifications.
Is there any way to bypass this "hidden" thing? Can i force the created channels to be visible for every user in the team, without the approving them first.
In theory, this function is controlled by isFavoriteByDefault, and when setting it to true, the channel should automatically be marked 'favorite' for all members of the team.
Unfortunately, after doing some research and test, I find that this property can't be changed through Graph API. So currently we can't bypass the "hidden" thing.
A similar post: Microsoft graph BETA add Microsoft Teams channel with isfavoritebydefault. The Microsoft engineer mentioned that could be they didn't fix the path POST /teams/id/channels.
I was able to add this but I see some inconsistency in the responses. For example if i run a flow that does the graph api process to create a channel within a team it only sets the show under channels for my account not the rest of the users associated with it. I don't know if anyone else has experienced this or has a fix.
Here is my sample:
{
"requests": [
{
"url": "/teams/{varTeamID}/channels",
"method": "POST",
"id": 1,
"headers": {
"Content-Type": "application/json"
},
"body": {
"displayName": "{varChannelName}",
"description": "This channel is in existence for",
"isFavoriteByDefault": true
}
}
]
}

Facebook Graph API not returning posts likes

I am trying to retrieve the number of likes for posts in a Facebook page. For instance, I am calling the following endpoint from Graph API explorer
nba?fields=posts{message, likes}
to retrieve posts from NBA page. But I only managed to retrieve message and id but not the likes. Is it because of new privacy policy?
`
{
"posts": {
"data": [
{
"message": "๐Ÿ˜ƒ๐Ÿ˜€๐Ÿ˜ฎ Does ANYBODY get better bench reactions than Klay Thompson??
๐Ÿ‘€: Golden State Warriors x Cleveland Cavaliers Game 3
๐Ÿ“บ: 9 pm/et Wednesday, #NBAonABC",
"id": "8245623462_10156593269718463"
},
{
"message": "๐Ÿ“ธ x #NBAFinals Game 2",
"id": "8245623462_10156593260853463"
},
{
"message": "Game 2 in #PhantomCam! ๐Ÿ‘€ the BEST of Stephen Curry, LeBron James, & more slowed all the way down.
NBAFinals presented by YouTube TV",
"id": "8245623462_10156592692223463"
},
{
"message": "George Hill added 15 PTS, 3 AST for the Cleveland Cavaliers in game 2 at Oracle Arena. #NBAFinals presented by YouTube TV",
"id": "8245623462_10156590505838463"
},
{
"message": "๐Ÿ—ฃ Stephen Curry somehow beat the shot clock with this WILD 3-pointer! Hear how it sounded around the world #GlobalGame ๐ŸŒŽ๐Ÿ€
`
https://developers.facebook.com/docs/graph-api/reference/v2.12/object/reactions
Likes are call "reactions" now ,(
thumb and , emoji reactions)
But I only managed to retrieve message and id but not the likes. Is it because of new privacy policy?
Yes. You will need admin access (page access token) now to get individual likes.
If you only want the number of likes though, you can ask for the summary field:
nba?fields=posts{message,likes.summary(1)}
And be aware, you will still need to get your app reviewed for Page Public Content Access, otherwise you wonโ€™t be able to get any info about pages you do not have admin access to. It works using above example link when using the Graph API Explorer app id - but as soon as you switch to one of your own, you will get an error saying you need PPCA, if the app in question isnโ€™t already approved for that.
Yes it is, more information than public available (by example the likes, now just called reactions) options will be closed soon.

How to set the tracking_specs when creating Facebook ads?

I am trying to create an ad using the Facebook Marketing API. In order to create an ad inside a conversion based campaign, I am required to set proper tracking_specs values.
Querying existing ads (on other similar campaigns) I see the tracking spec is generally defined as follows:
"tracking_specs": [
{
"action.type": ["offsite_conversion"],
"fb_pixel": [<pixel ID>]
},
{
"action.type": ["post_engagement"],
"page": [<page ID>],
"post": [<post ID>]
},
{
"action.type": ["link_click"],
"post": [<post ID>],
"post.wall": [<post.wall ID>]
}
]
How do I find the required tracking_specs values? More specifically, how do I find the post ID and the post.wall ID accordingly for post_engagement and link_click action types?
I managed to figure it out on my own. When creating a new ad, in a conversion typed campaign, an ad data object that includes tracking specs should be provided. These tracking specs should include some reference to a Facebook pixel.
"tracking_specs": [
{
"action.type": ["offsite_conversion"],
"fb_pixel": [<pixel ID>]
},
]
The pixels data can be obtained manually via the Facebook Business Manager or via the Facebook Marketing APIs:
GET /v2.10/{ad-account-id}/adspixels HTTP/1.1
Host: graph.facebook.com
Read more in https://developers.facebook.com/docs/marketing-api/reference/ad-account/adspixels/
Regarding the post and post.wall IDs - these are automatically added by Facebook when the ad is created. So there is no need to include theses when creating the ad.
For anyone searching for an answer in 2023. asaf's answer is totally correct BUT you also need to wait until Meta Business Manager processes your campaign in order to see tracking_specs into the API and in the Business Manager itself.

Why do I get this error when I try to access a certain type of object via the Facebook Graph API?

I have a user, user_2. There is a post on their wall, made by user_1.
The URL is
https://www.facebook.com/user_1/posts/10150166228506188
I try to get the content using the Graph API, with this request:
https://graph.facebook.com/10150166228506188?access_token=ACCESSTOKENUSER_2
I get this error:
{
"error": {
"type": "GraphMethodException",
"message": "Unsupported get request."
}
}
The access_token I am using is good, because requests to get things like statuses & images work fine:
https://graph.facebook.com/10150233707783933?access_token=ACCESSTOKENUSER_2
Result:
{
"id": "10150233707783933",
"from": {
"name": "American Steel",
"category": "Professional sports team",
"id": "203692078932"
},
"tags": {
"data": [
etc
The error seems to happen whenever I try to get items that have this kind of URL:
https://www.facebook.com/username/posts/item_id
The permissions my app has include these:
Why is this error occurring?
I think that, in order to access the posts directly through the graph api, you have to prepend the user id to the post id you see in the facebook url.
So in your example the facebook post url is :
https://www.facebook.com/user_1/posts/10150166228506188
And you try to get through the graph api :
https://graph.facebook.com/10150166228506188?access_token=ACCESSTOKENUSER_2
BUT you should be doing :
https://graph.facebook.com/{id of user_1}_10150166228506188?access_token=ACCESSTOKENUSER_2
I noticed that all posts ids are formed like this by visiting :
https://graph.facebook.com/me/posts?access_token=...
Does this solve your problem ?
You're accessing the end-point of the post incorrectly. Every object on Facebook has a unique ID. Right now, it just so happens that they form it by appending different IDs together (your post is an example, <user_id>_<post_id>, and for a comment on that post it'd be <user_id>_<post_id>_<comment_id>). Facebook hasn't made public acknowledgment of this (not that they really have to, it's obvious) which makes me leary to rely on that paradigm for accessing data within the graph. This is because Facebook could change it at any point, and the fact that they haven't said "yeah append these 2 ids together and you can get something meaningful from this part of the graph" means they won't have to notify anyone about the change, you could just wake up one day and your app be completely broken and you'd have to find a work around quickly and while suffering down time.
The graph api works by accessing objects on Facebook by making a request to the API for that unique ID. So, you don't need to access (and can't access) your posts by going to graph.facebook.com/<user_id>/posts/<post_id>. Instead, you go to graph.facebook.com/<post_id>. You get the post_id from the /<user_id>/home or /<user_id>/feed end-point on the graph. There is no need to modify a post_id in order to fetch information about it from the graph.
Hope that helps