Add domain to all vimeo videos by API - vimeo

We need to add domains to all of our videos. But I cant find a API call to add a domain to all of the videos - only one video at a time.
Right now I am doing two steps:
https://api.vimeo.com/me/videos....
Here I get all of our videos and their IDs and a hell of lot of stuff I dont need.
Then I loop through all of the videoIDs and call
https://api.vimeo.com/videos/{videoId}/privacy/domains/{newDomain} for each video.
This results in 1200 put requests which is not good. Furthermore I am not sure if we get banned with to many requests.
Is there som APIs that I have missed which supports what I am trying to do ?
Any help is appreciated.

Instead of using the API to do this, I suggest setting the default video privacy for all your videos at https://vimeo.com/settings/videos/upload_defaults - this includes the ability to add domain privacy.

Looking through the documentation I found an option for reducing the amount of data return. By adding e.g. &fields=uri,privacy to my api calls I reduced the amount of data returned.
I still have to loop each video and do a put however the first step is a lot faster.

Related

Dailymotion Advertising Api

I'm trying to get status about my video with dailymotion api. Some of videos are not getting ads. So i'm trying to understand how it's gonna be.
I tried like this but it's not telling about ads status.
String.Format("https://api.dailymotion.com/user/{0}/videos?fields=id,title,partner&limit=100&page={1}", userID, pageNumber)
i thought like partner key is enough to understand that situation but it's not. Can someone help me ? Also i tried to get something from http code but it didn't work.
Any suggestions ?
You can't know if ads will be displayed or not on a video. The AD server uses many criteria to determine what to do.
When the player is loaded on the page, a call to the ad server is sent in real time to know if an ad is available or not.
The API player provides some useful ad events, maybe you can use them: api events documentation

How to make basic REST API calls using a browser

I am trying to get started with REST API calls by seeing how to format the API calls using a browser. Most examples I have found online use SDKs or just return all fields for a request.
For example, I am trying to use the Soundcloud API to view track information.
To start, I've made a simple request in the browser as follows http://api.soundcloud.com/tracks/13158665.json?client_id=31a9f4a3314c219bd5c79393a8a569ec which returns a bunch of info about the track in JSON format
(e.g. {"kind":"track","id":13158665,"created_at":"2011/04/06 15:37:43 ...})
Is it possible to only to get returned the "created_at" value using the browser? I apologize if this question is basic, but I don't know what keywords to search online. Links to basic guides would be nice, although I would prefer to stay out of using a specific SDK for the time being.
In fact, it's really hard to answer such question since it depends on the Web APIs. I mean if the API supports to return only a subset of fields, you could but if not, you will receive all the content. From what I saw on the documentation, it's not possible. The filters only allow you to get a subset of elements and not control the list of returned fields within elements.
Notice that you have a great application to execute HTTP requests (and also REST) in Chrome: Postman. This allows to execute all HTTP methods and not only GET ones and controls the headers and sent content and also see what is received back.
If you use Firefox, Firebug provides a similar thing.
To finish, you could have a look at this link to find out hints about the way Web APIs work and are designed: https://templth.wordpress.com/2014/12/15/designing-a-web-api/.
Hope it helps you and I answered you question,
Thierry
Straight from the browser bar you can utilize REST endpoints that respond to a GET message. That is what you are doing when you hit that URI, you are sending an HTTP GET message to that server and it is sending back a JSON.
You are not always guaranteed a JSON, or anything when hitting a known REST endpoint. What each endpoint returns when hit with a GET is specific to how it was built. In that case, it is built to return a JSON, but some may return an HTML page. In my personal experience, most endpoints that utilize JSON returns expect you to process that object in a computer fashion and don't give you a lot of options to get a specific field of the JSON. Here is a good link on how to process JSON utilizing JavaScript.
You can utilize REST clients (such as the Advanced REST Client for Chrome) to craft HTTP POST and PUT if a specific REST endpoint has the functionality built in to receive data and do something with it. For example, a lot of wiki style REST endpoints will allow you to create a page with a specifically crafted HTTP POST with either specific header information, URI parameters or a JSON as part of it.
you can install DHC client app in your chrome and send request like put or get

obfuscate json from webserver

I've got an android and iphone app that both get the required data from a webserver. The data is sent via json to the client. Using this setup other people might simply retrieve the url the app is calling and this way could make use of the data that I gather with my scripts on the server. To make it short: I don't want that :)
My idea is to make the json unreadable for example by encrypting it. This would make it a little harder to retrieve the information since this way some who would like to use my service would had to decompile the app an lookup any decryption stuff I had implemented.
Therefore two questions:
Do there exist some libraries that already offer such a functionality (Server side is Java)?
Does anyone of you have any other suggestions how I could protect my api from unwanted guests?
Thanks in advance :)
I think the options available would be...
to lock down the API to Authorized/Authenticated users.
Using BSON to obfuscate the data.
You could always use oAuth to allow the users to authenticate based on an account they already have: Facebook, Twitter, Google etc.

Custom HTML5 Geolocation Prompt

As I am testing out one of the HTML5 features - geolocation for my project,
I realized that users can close the prompt without allowing or denying it,
that defeats the whole purpose of the prompt.
And because in my project I want to dynamically display data to users depending on user's location, this can't be done, simply because without knowing user's response,
it doesn't trigger any of the two callbacks - success / error.
so I started searching to see if there's any solution to this,
and a lot of suggestions to this is to set timeout,
I tried and everything works perfectly.
However, one small flaw here is tho, by the time it hits the timeout expiration,
all the data are already displayed, and when i say all, i mean EVERYTHING,
because there's no location detected.
So I came up with two solutions that might work,
1) create a custom geolocation prompt that forces users to allow/deny location to be shared,
and pass the response to browser to set the location preference
2) pause page-load (stop stuff from being rendered) and wait till it hits the timeout expiration or it gets response from users
Does anyone have any idea how to implement one of these two solutions?
PS: sorry if this isn't unclear to you, i know my english sucks, but I can explain in more details.
Thanks guys!
You shouldn't be able to use a custom Geolocation prompt if your project is browser based, because malicious developers could use the method to trick the user. Also, since the Geolocation API is an asynchronous event, it's going to continue loading the rest of the page while it waits.
What I recommend is to use a conditional statement instead with an else clause. This way, your script functions should only execute after location has been shared, and you have a fall back on what should happen if no geolocation information is provided (which I highly recommend as situations will occur when the data isn't provided).
Example of the conditional statement to check for geolocation information using JS:
if (navigator.geolocation) {
// code to run if there is geolocation information
}
else{
// code to run if no geolocation info is given to the browser
}

Is it possible to get scrobbling from information from last.fm API

I am getting information about the track I am listening to from last.fm.. I cannot however get the information about what I am scrobbling from, like you see on you last.fm page: "scrobbling now from spotify"
Does anyone know if this is possible without scraping the user page?
I don't see anything in the API docs - could easily be missing something.
The call I am using to get the now playing track is user.getRecentTracks which you use a attribute on the first song returned (nowplaying="true") to tell if its being played now and there is nothing about what I am listening on there.
The answer is: no, Last.fm API doesn't support this feature.
The only way you can get this information is to scrap it from <div class="scrobblesource">.