YouTube API | How do you reliably find channel's username or channelId? - request

For my application I need to retrieve a channel's ID, which can be done using a channel's username via channels().list(..., forUsername=username, ...).
The issue I have is that a channel's username is not as obvious as you would think. For example, talkSPORT's channel's username is actually talkSPORTMagazine. The only way I have been able to extract this is from their main page's URL.
talkSPORTMagazine
talkSPORT
However, a channel's main page's URL does not reliably include their username: sometimes it does, sometimes it includes their ID, or sometimes nothing at all.
If I don't use a channel's actual username then I cannot extract their channelID, something I need to request videos.
Is there a way I can reliably find a channel's username?

The answer to your question is unfortunately negative: there's no reliable way to find a channel's user name.
That's because user names are a legacy feature of the API v3: not every channel has one attached and no channel is required to have one attached. (See this official statement from Google staff from 2013-07-11.)
I warmly recommend to make your app such that it not rely on user names identifying channels; do arrange your app logic (both internal and external) such that to base it on channel IDs.
For what concerns channel URLs using user names, please follow this answer of mine: How to find the forUsername parameter for a specific channel.

Related

Remove "[External]" tags added by email server

My organization has begun adding obnoxious warnings to the subject and body of any email that arrives from an external address. My organization allows email forwarding, and I forward to gmail. I would like to have the extra text automatically removed before I see them in gmail. This would not violate the policies at my organization. Some ideas I had:
(1) One option would be to set up a gmail filter that edits the message. This feature does not seem to exist.
(2) Another option would be to customize the display so that this particular text is never shown on the screen. Again, there seems to be no way to do this.
(3) I wrote a script in Google Apps to grab to the content of each offending email and send an edited version to myself, but there is no way to make the "from" field show the original sender (perhaps with good reason). I can put that information in "reply to" but the gmail client doesn't show it nicely. This removes the annoying extra text at the cost of the ability to easily see who sent the email. The core of it is this call:
GmailApp.sendEmail("<my_email_address>",newSubject,newBody,{
attachments: message.getAttachments(),
bcc: message.getBcc(),
cc: message.getCc(),
htmlBody: newBody,
replyTo: message.getFrom(),
});
Any ideas? This is becoming a big problem as the "nanny state" approaches, so I'm sure others will appreciate your solution.
Issue
It unfortunately seems that at the day of this post, there is no way of edditing a forwarded email with the Gmail API. Check the documentation to see what you can actually do with the Gmail API in regards to forwarding email addresses.
Workaround
Despite it is not possible to edit a forwarding email address, in your case you are interested in:
Edit the body and subject of the email address.
Preserve the information of who the sender was.
Therefore what you could do is:
Get the email address you want to edit. Get the body, subject and information about who was sending it and store that.
Create a new message where you edit the message you just got and write on the subject the from field that was in the message you just got.
Send that created message to your desired recipient just like it was a forwarding email.
I hope this has helped you. Let me know if you need anything else or if you did not understood something. :)
Apps Script
You can insert messages into your inbox with their original "From" field but a modified body.
Note: Inserting is different from sending because the message is created on the inbox with less validation than sending.
To use this on Apps Script, take a look at the Advanced Gmail Service.
Custom Application
Another idea on how to do this is to use a custom application (in any language you'd prefer) that:
scans your company inbox with IMAP
manipulates the message body to remove the artifacts you don't want
insert manipulated message into your Gmail inbox with the Gmail API

how to add middleware/intercepter for every request in on dialogflow webhook server

how to add middleware/intercepter for every request in on dialogflow webhook server while using Action-on-google library and working with dialogflow application,
the purpose is i want to authenticate on every request that key is still valid or not, and also i want to check if that user is already managing a group then get all members of group and put in /userEntity,
now i'm doing this in wellcome intent, so when user say talk to xyz app in wellcome intent i check in database if user is managing a group then get all members of that specific group and put in user entity,
but this logic become trash when user directly say a command such as if user don't say talk to my xyz app and instead he says ask my xyz app john wink is present or not then app is unable to recognize this name, note that i cannot user system name entity because in my case these are not english names
for now i have restricted direct commands with context combination but it is not good e.g: user cannot say direct command unless WELCOME_DONE context which is context out of wellcome intent
The "direct command" you mention (ask my xyz app john wink is present or not) is what we call an "action invocation phrase". Since you're depending on a user entity in order to extract a name from the action phrase, you'll only be able to do this successfully if another intent has recently been matched, since the user entities you add are only available for 30 minutes.
One way around this might be the following. We are going to do something clever to run the user query through Dialogflow a second time, after adding the user entity.
In the intent that handles your "action invocation", use #sys.any (which is essentially a wildcard entity) to capture the name. Enable the webhook for this intent.
Create another intent with User says examples that match the expected "action phrase", similar to the first intent, but don't add it to your "Additional triggering intents". Enable the webhook for this intent.
Create a function in your webhook that handles the intent from Step 1.
In this function, look up the user and their group and add the members via /userEntity.
Now that the user entity has been created, call the Dialogflow /query API with whatever the user said.
Since the user entity has now been created, the intent created in Step 2 will be matched, so the /query API response will contain the name from the entity you created in Step 4.
Use the name to generate whatever response you wanted to generate.

Alexa account linking - How to store more than access token

When I link an account with a third party they send an access token as well as the user's username.
Alexa automatically saves the access token and gives it with each request. How can I get it to save the username as well?
This is intentionally not supported in order to protect the user's privacy. That is a good thing.
Alexa does provide a userID with each call. This id is specific to each user, and the same every time they use your skill. It doesn't give you any personal information, but it does allow you to save information for each user to your own database. You can associate that user's data with the userId and recall it every time they use your skill.
So for example, you can ask the user for a name, save it to your database keyed by the userId, and recall it at a later date using the userId.
Search on "alexa user information" for more info, for example this post.
Just encode the user name and/or any other information to the token itself.
For example you can use JSON Web Token - https://jwt.io/ - wich is an RFC 7519
It is intended exactly for the use case when you you don't want to make an additional request(s) just to retrieve some rarely changing info.
Regards caching/refreshing you can issue token for limited amount of time (an hour?).

Does exposing a user's uid in the url pose a security threat for Firebase?

I've got a small review system built in AngularJS and Firebase and the only way to identify which review is made by which user is via the uid of the user. The idea is when you then click on the user's name, you should be taken to the profile of that user.
So I would then create a route looking like /profile/{{review.author.uid}} which could translate into /profile/facebook:123234243 for example.
My question is, does it pose a security threat showing the uid in the url like this? Can it be used for any malicious actions against a user's third party account etc?
I've tried looking through their website but I can't find anything on this subject.
EDIT: Note that I need a Firebase specific answer, not a generic one about database id:s.

Integrate SurveyMonkey in an existing community

I have a cakePHP community. User are able to signup and login. I like to create a survey using SurveyMonkey.
Therefor I create the survey and make it available to my members using the direct URL. In my member database I have to save the information "did completed the survey = yes/no".
Is there any way to identify the user filling in the survey and write this information into the database?
SurveyMonkey has an API https://developer.surveymonkey.com/ , that let you collect info from your survey (completedf or not).
This is the only way i think, (if it s not include in your website).
I know that you can simply do this with Examinare Survey Tool. What you do first is that you use the API inside Examinare to add a recipient for all the users in the survey base.
Use the PHP Wrapper library in their developer site.
Loop it through and use the https://developer.examinare.com/php-wrapper-library/ and use the example code.
If you let people register with same email more than 1 time then save the ContactID into your database on the recipient.
Then to not create an email invite you use this : markrecipientstosurvey
The surveyID is available inside the Examinare account.
When you done this script part then make it as a cronjob for instance inside the crontab -e
I would run it every 30 minutes or 1 per hour.
Next part you create a page for the survey redirect where you use the function: listsurveysbyuser
to get the survey version and url
(there is a special link for the mobile user that even works for the normal mobile phone NOT only smartphones)
Now you just redirect them to the survey. If you want them to return to your site after then you use the redirect_url parameter that is added to the url or use the redirect inside your account. Ask support about that if you need :) They are fast... Never had to wait more than a couple of minutes.
When the person return then just check if they are marked as complete with the same api call: listsurveysbyuser
Looks much but it is very easy to implement and if you have any problems then just ask the support at support#examinare.com I have asked alot and never had them to say that it can not be done. Really nice!
EDIT:
I see that they just released a tutorial much better than my example:
https://developer.examinare.com/how-to-use-surveys-in-cakephp-with-very-little-development/
One option:
Use unique Custom Variables in the URL that is visited by each member of the community
For example, https://www.surveymonkey.com/s/your_survey?userid=$my_user_id
Note that you can create weblink or email collectors with the API (endpoints: create_flow or create_collector).
Then track the responses using the get_respondent_list or get_responses endpoints of the API.
Note: Please confirm with the Survey Monkey API team that the custom variables can be read via the API.
Another option:
Use the email collector (create_flow) API endpoint and send it to your members' email addresses.

Resources