How do I post a snippet to slack channel - slack-api

I am trying to post log info to slack and some of these logs can get pretty big. Is there a way to send it as a snippet so that slack doesn't chunk the text into multiple messages?

You can post a snippet to a Slack channel using the API method files.upload.
In order for this to work you need to:
Use the content (not the file) parameter to upload the content of
your file.
Provide the name of the channel in the channels parameter where the
snippet should be posted.
The filetype is optional. Slack will determine the type of your
file based on the filename or "magic bytes" of the file. e.g. using
text as filetype will work.

Related

Set Excel / Word Online document readonly using Graph API

When an Excel or Word file on SharePoint is opened,it is in edit mode by default.From Excel/Word online menu, there is a menu option to set the file read-only, called "Protect Workbook" in Excel inline and "Protect Document" in Word online, as shown in the screenshot.
Next time the file is open in Excel/Word online, it is opened in read-only mode and shows an "Edit Anyway" button to switch to edit mode, which is exactly what I need.
Question is: How can I use Graph API to programatically set an Excel or Word document as read-only?
HTTP request
POST /workbook/worksheets/{id|name}/protection/protect
Request headers
Name Description
Authorization Bearer {token}. Required.
Workbook-Session-Id Workbook session Id that determines if changes are persisted or not. Optional.
Request body
In the request body, provide a JSON object with the following parameters.
Parameter Type Description
options WorkbookWorksheetProtectionOptions Optional. sheet protection options.
Response
If successful, this method returns 200 OK response code. It does not return anything in the response body.
Kindly look at https://learn.microsoft.com/en-us/graph/api/worksheetprotection-protect?view=graph-rest-1.0&tabs=http for more Information

url field is not getting recognised in Watson Discovery service during conversion

Inline with this thread
How do we get the document file url using the Watson Discovery Service?,
I tried adding url field inside HTML document under various tags like p, directly as
<"url">...<"/url"> etc inside <"body"> tag.
Whatever I do, this url field that I am trying to add is not getting reflected either under extracted_metadata or under html or under text in the json when I see the resulting json after conversion / enrichment in the discovery tooling. Can someone throw some hint on what I can do to get url field just like title under extracted_metadata section in the json output?

Can you explain on theme jsPDF? How to write code where be generated by the file and sent in the mail which will indicate the user.

Can you explain on theme jsPDF? How to write code where be generated by the file and sent in the mail which will indicate the user. Thanks
If you are on about how to create a jsPDF file that is generated by Javascript and then sent by email to a user, this is certainly possible. You could use the example script below and then use a server to send the form to the user using PHP for example, such as PHPMailer. You would obviously need to get the name of the user stored in a variable and pass this into the PHP request for sending the form.
Sample taken from jsPDF Example
var doc = new jsPDF();
doc.setFontSize(22);
doc.text(20,20,'This is a title');
doc.setFontSize(16);
doc.text(20,30,'This is some normal sized text underneath.');

How to get the full direct message using twitter REST API

I tried to use the following endpoints to get the contents of one or more direct messages:
direct_messages.json
direct_messages/show.json?id={id}
The messages are returned correctly, the only problem is that the text of the message is truncated to ~140 chars, and the final part of the message is substituted with a shortened link ( t.co ), that when open points to https://twitter.com/messages/(\d+)-(\d+)
The link can't be opened using the REST API, and I have no idea how to retrieve the last part of the message.
you just have to add full_text=true as stated here: https://twittercommunity.com/t/removing-the-140-character-limit-from-direct-messages/41348

Decode url_encoded_fmt_stream_map to valid Url

Im using url_encoded_fmt_stream_map to get a List of Youtube VideoStream "urls".
I want to use these urls to show Youtube videos in my VideoView.
My method pretty much returns a String Array containing Strings like this:
sig=3E0D90E459ADEF9F88553D716B9275930A8AA418.AD0319F9287244E34CCA97F7DE245C0606DD46C5&itag=45&fallback_host=tc.v22.cache5.c.youtube.com&url=http%3A%2F%2Fr4---sn-uigxx50n-8pxl.c.youtube.com%2Fvideoplayback%3Fsparams%3Dcp%252Cid%252Cip%252Cipbits%252Citag%252Cratebypass%252Csource%252Cupn%252Cexpire%26id%3D4e6580527662c67d%26cp%3DU0hVSVlQV19FUENONV9RSkFIOnZ3SkZXb3hfdUdp%26source%3Dyoutube%26fexp%3D919110%252C913564%252C916624%252C932000%252C906383%252C902000%252C919512%252C929903%252C931202%252C900821%252C900823%252C931203%252C931401%252C909419%252C913566%252C908529%252C930807%252C919373%252C930803%252C906836%252C920201%252C929602%252C930101%252C930603%252C900824%252C910223%26ms%3Dau%26mv%3Dm%26mt%3D1364933359%26sver%3D3%26itag%3D45%26key%3Dyt1%26ip%3D178.115.248.80%26newshard%3Dyes%26upn%3DNLMBgU-0oUc%26expire%3D1364959706%26ipbits%3D8%26ratebypass%3Dyes&quality=hd720&type=video%2Fwebm%3B+codecs%3D%22vp8.0%2C+vorbis%22
If you have a close look at it, you can see that this String actually contains valid information. Unfortunately I have no idea how to extract a valid url out of this.
How would I do that?
If I create an URI with the String above and add it to my VideoView, a message "Can't play this video." pops up.
As you probably know, youtube link looks like that:
http://r6---sn-nhpax-ua8l.c.youtube.com/videoplayback?algorithm=throttle-factor&burst=40&cp=U0hVTFlTUV9HUUNONV9RTVVCOkk4ams1XzRlZUpq&cpn=qAthIxAZB16Q6_qB&expire=1367983127&factor=1.25&fexp=927900%2C919357%2C921716%2C916623%2C922911%2C931009%2C932000%2C932004%2C906383%2C904479%2C901208%2C925714%2C929119%2C931202%2C900821%2C900823%2C912518%2C911416%2C930807%2C919373%2C906836%2C926403%2C900824%2C912711%2C929606%2C910075&id=932a6c200e40b791&ip=84.228.249.95&ipbits=8&itag=34&key=yt1&ms=au&mt=1367957244&mv=m&newshard=yes&ratebypass=yes&signature=7E86D1813AE13CEB544CFF3749FBD042FF50EE91.AF7D6D9DCF286D291825630E733B3407683C46C9&source=youtube&sparams=algorithm%2Cburst%2Ccp%2Cfactor%2Cid%2Cip%2Cipbits%2Citag%2Csource%2Cupn%2Cexpire&sver=3&upn=t0jDC5Yk7Go
And as you said, all the parameters we need are shown in your string.
There are 2 important parameters we need to extract from your string: url and signature.
The Link eventually should look like this: url + "&signature=" + sig.
You can take a look at my code, where I extract all the available links out of youtube link. It's wriitten in java for an android app: link
Thank you for your effort.
I solved this problem by sticking to the official YouTube API. Also see this question:
Getting YouTube Video ID including parameters

Resources