BOX API to invite external user - rest

Just am trying to use BOX API for collaboration. i just wanted to know is there any REST api call available to invite a external user.

You just POST to https://api.box.com/2.0/collaborations with the proper auth header for your user that is authenticated (the person doing the invitation to collaborate). In the body of the request you would put the JSON to specify the folder and the invitee.
{"item": { "id": "12137", "type": "folder"}, "accessible_by": { "login": "rob#winterfell.com"}, "role": "editor"}
Then rob#winterfell.com will get an email telling them that they've been invited to see the appropriate folder.

Related

Is there an API for sharing an attachment in RingCentral Glip?

I want to build an app that can monitor one Glip team for posts including screenshots and then post that message to another Glip team. I can read a post, download an attachment and repost / upload it, but is there a way to simply share an existing attachment without reposting it. This can be done in the app UI but I didn't see a share API in the Glip API Reference.
Here's the Glip API Reference which includes endpoints for creating, reading, updating and deleting posts but not sharing:
https://developers.ringcentral.com/api-reference/team-messaging
The icon for sharing is the 6th from the left in the app screenshot below.
Is there a way to do this in Glip without downloading and re-uploading the file?
To share an attachment via the Glip API, create a new post with an existing attachment.
Create Post API
The Create Post API takes an optional attachments array which references existing attachments. Both the id and type properties are required. Both properties are present in the post API response.
POST /restapi/v1.0/glip/chats/{chatId}/posts
{
"text": "Please check out this file",
"attachments": [
{
"id":"123456789",
"type":"File"
}
]
}
Ref: https://developers.ringcentral.com/api-reference/Posts/createGlipPost
Example Get Posts API
The following is an example of a post showing the attachments array with the id and type properties. The attachment URL is an AWS Presigned Object URL as shown below.
GET /restapi/v1.0/glip/chats/{chatId}/posts
{
"records": [
{
"id": "11111111",
"creatorId": "22222222",
"creationTime": "2019-08-26T21:41:56.648Z",
"lastModifiedTime": "2019-08-26T21:41:56.648Z",
"type": "TextMessage",
"chatId": "33333333",
"mentions": [],
"attachments": [
{
"id": "123456789",
"name": "sharedfile.png",
"contentUri": "https://glip-vault-1.s3.amazonaws.com/web/customer_files/44444444/testimage.png?Expires=55555555&AWSAccessKeyId=myAccessKeyId&Signature=myAWSPresignedObjectUrlSignature",
"type": "File"
}
],
"text": "Check this out!"
}
},
"navigation": {}
}
Ref: https://developers.ringcentral.com/api-reference/Posts/readGlipPosts
Sharing Permissions
Attachments can only be shared by the original poster or within the same chat. If a different user wants to share an attachment in a different team, it will be necessary to download and repost the file, generating a new attachment id.
If a different user attempts to share an attachment in a different chat, a 403 Forbidden error will be encountered:
403 Forbidden
{
"errors": [
{
"errorCode": "PST-011",
"message": "The requester must be attachment creator or attachment must belong to the requested chat."
}
]
}

Skype Bot sending message (not a reply)

Trying to create a Skype Bot, but I have a problem. Please, help me.
I use PHP so I use REST (not NodeJS or C# SDK).
The task: I have to send data from html form on my website to Skype (so I don’t have to reply to a message, but just send).
Well, I have successfully create a bot in Microsoft Bot Framework.
Then I have successfully received an access_token.
Then they say in docs that I have to send a POST to:
/v3/conversations/{conversationId}/activities
According to https://learn.microsoft.com/en-us/bot-framework/rest-api/bot-framework-rest-connector-send-and-receive-messages I have to send a request to /v3/conversations with JSON like that:
{
"bot": {
"id": "12345678",
"name": "bot's name"
},
"isGroup": false,
"members": [
{
"id": "1234abcd",
"name": "recipient's name"
}
],
"topicName": "News Alert"
}
But what is the "member's id and member's name"?
To get the member ids of some members, add all those members in a group and add the bot, too, to the group and preferably send a message in the group, mentioning the bot. You will receive a json with a conversationId. With this conversationId, make a get request to v3/conversations/{conversationId}/members in order to receive the member-ids and member-names of the members in the group.
You can now proceed with these member-ids and member-names to start individual conversations with the members (which is illustrated in my answer to this question).

setting event organizer with Outlook Calendar REST API

I am using the Outlook REST API for creating events and sending its invitations, based on this documentation
I authenticate the logged in user, and send its Bearer token through the Authorization header of the request, and the json-formatted event on its content.
If I set the "Organizer" to another user rather than the authenticated one, as well as the "IsOrganizer" property to "false", it gets totally ignored and sets the current logged in user as the organizer.
Any clues of what could be happening?
Is there another way of doing this?
Thank you!
I'm posting this in case someone else finds and needs an answer for this scenario...
You (Account A) can create a calendar event as someone else (Account B) through Office365 REST APIs as long as the account has permission to send as the other user account.
Here are the steps:
1) Call the Office365 REST API as follows,where {{{user2email}}} is the user you want the event to be created as (Account B's email address):
https://outlook.office365.com/api/v1.0/users/{{{user2email}}}/calendar
This should return Account B's user's calendar ID.
2) Pass in your JSON - the following is an example of what I used during unit testing:
{
"Subject": "Test - Created using Office365 Calendar REST API should be from Technology Notice",
"IsOrganizer": "False",
"Body": {
"ContentType": "HTML",
"Content": "This is where body copy goes HTML supported"
},
"Start": "2015-12-11T19:00:00Z",
"End": "2015-12-11T20:00:00Z",
"Attendees": [
{
"EmailAddress": {
"Address": "attendee1#yourcompany.com",
"Name": "Attendee One"
},
"Type": "Required"
}
],
"Organizer": {
"EmailAddress": {
"Address": "tnotice#yourcompany.com",
"Name": "Technology Notice"
}
}
}
'Technology Notice' will be who the calendar invite is from.
3) Use the ID from step 2 in your POST request, for example:
https://outlook.office365.com/api/v1.0/users/{{{user2email}}}/calendars/{{{ID}}}/events
Note: Make sure you're sending the POST request as the authenticated user account (Account A) who's account the mailbox/calendar it actually belongs to.
If everything is right you should be able to send a calendar invite and have it show up as originating from Account B instead of Account A.
Hope this helps someone out.
This is the correct behavior. You cannot create an event on User A's calendar but set the organizer to User B.

How to get a Facebook access token that has enough rights to get the posts in which you're tagged in?

The Facebook posts in which you're tagged in - using #Name - appear in your wall feed.
A friend of mine posted a link and tagged me in it:
On the Graph API documentation, when I click on my wall feed link (Ctrl + F: Profile feed), I'm able to see this post:
...
{
"id": "XXX",
"from": {
"name": "XXX",
"id": "XXX"
},
"to": {
"data": [
{
"name": "XXX",
"id": "XXX"
},
{
"name": "Christophe Maillard",
"id": "XXX"
}
]
},
"message": "The startup Guide (cc XXX, Christophe Maillard)",
"link": "http://mashable.com/2012/06/27/startup-guide-1000-users/",
"name": "How to Get to Your First 1,000 Users",
"caption": "mashable.com",
"description": "With the help of some smart marketers and entrepreneurs, we're created a clear outline for attracting your startup's first 1,000 users.",
...
}
...
The URL of this feed is https://graph.facebook.com/me/feed?access_token=XXX.
When copy/pasting the given access token - the one replaced by XXX in the URL above - within the debugger, I get something like this:
As we can see, the access token is generated by the app Test_console which used quite a lot of scopes.
Then, I go to the Graph API Explorer, I generate an access token using the Get Access Token button, and I specify all the scopes the debugger gave me, i.e. the ones the Test_console app used to generate its working access token. Finally, I access the URL me/feed by submitting the GET request. The problem: I can't see the post in question in which I'm tagged in with the explorer.
I also have my own app, and it reacts exactly like the Graph API Explorer: I can't find that post in my wall feed using the Graph API as well.
Obviously, it's possible to get the posts in which you're tagged in using the Graph API, because the Test_console app is able to generate an appropriate access token. But how can I get such an access token for my own app?
You need to grant the appropriate permissions for your app. In the graph api explorer https://developers.facebook.com/tools/explorer?method=GET&path=me switch to your app in the applications field (top right) to see what permissions that currently grants your app (by clicking the "get access token" button again). Then make sure you add in the correct one (i think it's read_stream you're after ) https://developers.facebook.com/docs/authentication/permissions/

Facebook: Link Request's sender to it's recipient?

When using the requests dialog, facebook issues a notification like this:
What I'm looking to achieve is for the user to click the request link shown above and to present a "Random User invited you to..." message on our App.
However, when clicking that link Facebook doesn't seem to pass through the id of "Random User" to the App. The url accessed by the link looks something like:
http://apps.facebook.com/randomcomp/?fb_source=notification&request_ids=350578327437399,350578327437399&ref=notif&app_request_type=user_to_user&notif_t=app_request
which doesn't contain any reference to the user who initiated the request.
From the App's side, there doesn't seem to be a way to get this information from Facebook. Sure, you can get a list of requests, but that list can contain information for many requests, including requests from other users in addition to the one we're interested in, so it's not useful in this case. For example, here's a snapshot of data:
{
"data": [
{
"id": "340083146057323_100003817986566",
"application": {
"name": "Random Competition",
"namespace": "randomcomp",
"id": "350578327437399"
},
"to": {
"name": "Hannah Smith",
"id": "100003817986566"
},
"from": {
"name": "Random User",
"id": "100002286042525"
},
"data": "100002286042525",
"message": "Use the app!",
"created_time": "2012-05-14T13:26:30+0000"
}, {
"id": "358318457550141_100003817986566",
"application": {
"name": "Random Competition",
"namespace": "randomcomp",
"id": "350578327437399"
},
"to": {
"name": "Hannah Smith",
"id": "100003817986566"
},
"from": {
"name": "Jane Young",
"id": "100003771838663"
},
"data": "100002286042525",
"message": "Use the app!",
"created_time": "2012-05-14T10:54:25+0000"
}],
}
}
As you can see, the data is being passed in, but there's still no way to join the click from the link mentioned above (for Random User) to the correct request in the list; the link passes through the ID for both requests, not just the one for Random User, and while the link states "Random User" it doesn't pass through an identifier.
Am I missing something? Is there a mechanism that isn't in the docs that will allow me to pick-up the "Random User" id so I can provide a nice "Random User invited you to..." message in the App when they click through?
Edit:
Turns out that this isn't possible - see my answer.
You can add some data to the request so that when you process the request you can differentiate that from other requests.
The data can be sent with app requests and users requests and the parameter name is "data".
For example, in the guide for the Requests Dialog you can see it in the properties table at the (almost) end of the document, it says:
Optional, additional data you may pass for tracking. This will be
stored as part of the request objects created. The maximum length is
255 characters
There's also some info about it in the Social Channels documentation, and a sample of (php) usage in the official blog post about Upgrade to Requests 2.0.
I hope that this is what you're looking for.
Edit
When you send the request you know who is sending it right? It's the logged in user, and so you can put the user id/name/etc in the data parameter of the request.
Then, when someone clicks on a request, get the request by the id that facebook passes to you, and from the data extract the user id of the sender.
As the documentation states, you have 255 characters to use, and with that you can do what ever you want, you can even serialize an object to that parameter and deserialize it later.
As it turns out, this is in fact not possible at all.
The link, as shown in the image below, can present multiple users:
which is why multiple request IDs are passed in, and the sender's ID isn't.