Instagram Subscription - instagram

I have followed Instagram documentation (https://www.instagram.com/developer/subscriptions/) on how to create a user subscription.
This is the response that I get after creating the subscription:
{
"meta": {
"code": 200
},
"data": {
"object": "user",
"object_id": null,
"aspect": "media",
"subscription_id": 0,
"callback_url": "http://CALLBACK_URL",
"type": "subscription",
"id": 0
}
}
Some of the users that have authenticated with my app have posted some media and yet I'm not seeing anything from my end, which makes me think that there might be an error with the subscription.
subscription_id or id 0 does not look correct to me. My app is still in Sandbox mode, is this the problem?
Also, I have tried creating another subscription with object=tag and object_id=blah but it returns the same response as above.
Any advice would be very much appreciated. Thank you!

The subscription_id=0 looks weird but it's normal in sandbox. Perhaps you can make sure your callback url is actually receiving the post from Instagram properly (save it to a log to test).

Related

Whatsapp Cloud API webhook not sending back the messages object

One of my WA cloud Apps suddenly stopped working,
I went to the webhook and it is not sending the messages object back,
I am sure this happened suddenly
here is the result from webhook:
{
"object": "whatsapp_business_account",
"entry": [
{
"id": "1900820329959633",
"changes": [
{
"value": {
"messaging_product": "whatsapp",
"metadata": {
"display_phone_number": "16315551234",
"phone_number_id": "16315551234"
},
"statuses": []
},
"field": "messages"
}
]
}
]
}
Meanwhile if you go to official WA Postman collection you will find that it already includes messages object.
Edit 1:
After some investigation I found that developer.facebook health check page has the following:
But still not sure if that's related.
Is there anything I can do to fix this?
Edit 2:
I tried another developer account that has cloud API, it works and sends back the messages Object correctly.
EDIT 3:
Now they are describing the same issue occurred.
I have been able to report a bug to WA Team, and they were able to reproduce the error.

Microsoft Graph create share link for specific people

I would like to share document by link in sharepoint from microsoft graph code. Default behaviour is that every person who has link can see this file. I want to make this link working just for specific people.
So my code look like this:
Permission permission = await _graphClient.Sites[_options.SiteId]
.Drives[driveId]
.Items[itemId]
.CreateLink("view", "organization")
.Request()
.PostAsync();
This create share link for all people in organization. Now I would like to grant permissions (https://learn.microsoft.com/en-us/graph/api/permission-grant?view=graph-rest-1.0&tabs=csharp)
await graphClient.Shares["{sharedDriveItem-id}"].Permission
.Grant(roles,recipients)
.Request()
.PostAsync();
But I have no idea what should be in place "{sharedDriveItem-id}". When I put there itemId it doesn't work. Also if I put there permission.link.webUrl it also doesn't work.
What am I doing wrong?
From this documentation.
Once you create the shared link the response object returns an id, that's what you should use in place of the {sharedDriveItem-id}. See a similar response object below.
HTTP/1.1 201 Created
Content-Type: application/json
{
"id": "123ABC", // this is the sharedDriveItem-id
"roles": ["write"],
"link": {
"type": "view",
"scope": "anonymous",
"webUrl": "https://1drv.ms/A6913278E564460AA616C71B28AD6EB6",
"application": {
"id": "1234",
"displayName": "Sample Application"
},
},
"hasPassword": true
}
Okey, I found solution. There are few steps:
As sharedDriveItem-id I used encoded webUrl following by this instruction https://learn.microsoft.com/en-us/graph/api/shares-get?view=graph-rest-1.0&tabs=http
When I was creating link (https://learn.microsoft.com/en-us/graph/api/driveitem-createlink?view=graph-rest-1.0&tabs=http) in place scope i put "users"- there is no option like that in documentation but without that it doesn't work
I added Prefer in header https://learn.microsoft.com/en-us/graph/api/driveitem-createlink?view=graph-rest-1.0&tabs=http
I was using clientSecret/clientId authorization so I had to add azure app access to Sites.Manage.All and Sites.FullControl.All in Graph Api Permissions
Everything works If you using Microsoftg.Graph nuget in newest version (4.3 right now if I remember correctly)

Requesting User Location from Google Actions with Api.ai

Google Actions can provide you with the user's location, name, and few other details. How can this be done on Api.ai without the nodejs SDK? All examples from Google are using the Nodejs sdk.
According to the Conversation Api it is just a matter of putting the correct json in the response, however it is unclear how to get Api.ai to fill in this json.
I've read the docs here , but am still unclear.
Sample code, or more detailed documentations, would be great for the non nodejs developers. I'm working in Java, however a good explanation of how Api.ai builts the response json for Google Actions would be helpful for developers of all languages.
You have to study the API.AI HTTP API here. As a reference, try to setup the node examples - this way you can see the JSON files in action.
For the permissions try the Name Psychic example.
Your outgoing JSON will be something like this:
{
"contextOut": [
{
"lifespan": 100,
"name": "_actions_on_google_",
"parameters": {}
},
{
"lifespan": 1,
"name": "requesting_permission",
"parameters": {}
}
],
"data": {
"google": {
"expect_user_response": true,
"is_ssml": false,
"no_input_prompts": [],
"permissions_request": {
"opt_context": "To send you something",
"permissions": [
"DEVICE_PRECISE_LOCATION"
]
}
}
},
"speech": "PLACEHOLDER_FOR_PERMISSION"
}
There is now another option for Java programmers working with Actions on Google. There is an open source port of the official SDK to Java/Kotlin. API is very similar, so for location it would be something like:
app.askForLocation()
https://github.com/TicketmasterMobileStudio/actions-on-google-kotlin

Api version change but docs not updated?

I've been trying to do various things through your Mail REST API today and not having much success... My project (using the api) has been running for at least a month now, but requests to your api are failing.
For example:
GET https://outlook.office365.com/EWS/OData/Me/messages (works)
GET https://outlook.office365.com/EWS/OData/Me/inbox (doesn't work)
Looking at the documentation, still says its available.
Trying to send an email using:
POST https://outlook.office365.com/EWS/OData/Me/Messages?MessageDisposition=SendAndSaveCopy also just returns 400 (Bad Request)
Any info about this?
Also, the http status codes returned are not useful at all; almost all errors return as 400's. In one instance, I didn't provide auth creds, and a 400 was returned instead of the appropriate 401. The accompanying status code detail could also be more helpful.
Thanks for the feedback and sorry for the inconvenience. We are currently deploying some non-backwards compatible changes described here, and this is causing your issues. The current set of changes including versioning support, and deploying non-backwards compatible changes won't cause issues for your app in the future. For the queries, that don't work, please use the following:
Accessing Inbox: https://outlook.office365.com/ews/odata/me/folders/inbox
Send email (new action called SendMail):
POST https://outlook.office365.com/ews/odata/me/sendmail
{
"Message":
{
"Subject": "Test message",
"Body":
{
"Content": "This is test message!"
},
"ToRecipients":
[
{ "EmailAddress": { "Address": "John#contoso.com", "Name": "John Doe" }},
{ "EmailAddress": { "Address": "Jane#fabrikam.com", "Name": "Jane Smith" }}
]
},
"SaveToSentItems": true
}
Hope this helps. We are updating the documentation to reflect the changes, and it should be available shortly. Thanks for the feedback on the HTTP status codes, we will review the status codes returned currently and make any fixes required.
Conversation support is in our roadmap but we don't yet have a timeline to share. Currently, you can search using https://outlook.office365.com/ews/odata/Folders/FolderId/Messages?$filter=ConversationId%20eq%20%%27ConversationID%27 but this will only return messages within the specified folder belonging to that conversation.
Let me know if you have any questions or need more info.
Thanks,
Venkat

GitHub API v3: Determine if user is an Owner of an Organization

It's easy to determine if a User is a member of a Team if you know the id:
GET /teams/:id/members/:user
But how can one easily determine the ID of the special "Owners" team that every Organization has?
As far as I can tell, the only way is to retrieve a full list of all Teams (which I assume may be multiple pages?) and walk through them until you find one with the name "Owners".
This is doable of course, but it's uncharacteristically inconvenient for GitHub's otherwise fantastic API. ;)
For what it's worth, I've tried the following (with no luck):
GET /orgs/:organization/teams?name=Owners # Lists all teams
GET /orgs/:organization/owners # 404
Just to be clear, I've made sure to use a token associated with the user that owns the organization in question, so there shouldn't be any authorization issues.
There is currently no easy way to check if a user is in the owners team. Thanks for the cool feature suggestion, though! ;)
A hacky workaround would involve performing a non-destructive operation which only owners are allowed to do. If the operation succeeds - the authenticated user is an owner.
For example, you could try editing the organization's settings by sending an empty JSON hash:
$ curl -v -X PATCH -d '{}' https://api.github.com/orgs/:org?access_token=TOKEN
If this returns a 200 status code, the user is an owner. A 404 status code signals otherwise.
Hopefully we can provide a more elegant solution in the future.
As an alternative, quicker solution, you can use the memberships API to get details about the authenticated user's membership to each organization they belong to.
The request is simply GET /user/memberships/orgs?state=active, and the response looks like this:
[
{
"state": "active",
"role": "admin",
"organization": {
"login": "octocat",
"id": 1,
},
"user": {
"login": "defunkt",
"id": 3,
"gravatar_id": "",
"type": "User",
"site_admin": false
}
},
{
"state": "active",
"role": "member",
"organization": {
"login": "invitocat",
"id": 2,
},
"user": {
"login": "defunkt",
"id": 3,
"gravatar_id": "",
"type": "User",
"site_admin": false
}
}
]
The important field to note is role; we only want "role": "admin".
I'm not sure that this guarantees that the user is a member of Owners, but it does indicate that they have administrative powers of the organization.
Simply determine if they are part of the team named "owners" for that org https://developer.github.com/v3/orgs/teams/#list-team-members
Owners are a special team for GitHub with only owners.
See https://github.com/orgs/YOURORG/teams/owners

Resources