Models.Link.getType in Spotify Apps API V1.0.0 - api

In pre V1.0 Spotify Apps API you could do...
var uri_type = models.Link.getType(playlist_uri); // returns 5 (number)
To find out if a URI is a Track, Playlist, Album etc...
http://developer.spotify.com/docs/apps/api/0.1/506827d4e4.html
But I don't see anything similar in V1.0.0 of the apps API.
https://developer.spotify.com/docs/apps/api/1.0/
Anyone know if something similar is in the new API?
Cheers

If you need it to determine the type in order to know what type to use when loading the URI (e.g. Playlist.fromURI, Artist.fromURI), you could use models.fromURI(String uri).
Furthermore, if you'd like to know exactly which type was loaded, you can check the constructor.name property of the loaded object. For example,
require(['$api/models'], function(models) {
var loadable = models.fromURI("spotify:artist:18iQQOuyGlHunPVzmoLY20");
console.log(loadable.constructor.name);
});

Related

Sharepoint error: Likes are not supported in this item

I'm trying to create a Sharepoint iOS app and using the rest api I get the error "Likes are not supported in this item." after doing a POST to https://tenant.sharepoint.com/News/_api/web/lists/getbytitle('pages')/items('1234')/like.
Anyone knows more about this kind of error?
The Rating settings seems to be set correctly on the Sharepoint server, because the like option works correctly on the website, and also in the app I can see the likesCount properties on the response for the Rest API call https://tenant.sharepoint.com/News/_api/web/lists/getbytitle('pages')/items('1234').
I don't think there is something wrong with the client app implementation, but it is something related to the Sharepoint configuration, although I haven't seen any more settings in regards to the Rating settings including the Sharepoint access for the mobile app.
The web seems to handle this using the Microsoft.Office.Server.ReputationModel.Reputation.setLike function which again works correctly on the web parts, but I couldn't find a way to do it from the mobile app.
To set Likes for the list item, we need use the API below with POST request.
https://tenant.sharepoint.com/News/_api/web/lists/getbytitle('pages')/items('1234')
And pass the data of the POST request as below.
var item = {
"__metadata": { "type": "SP.Data.PagesItem"},
"LikedByStringId": {"results": ["11"]},
"LikesCount": 2
};
Before set Likes for the item, we need get the "LikedByStringId" and "LikesCount" value of the list item using API below with GET request, then set the new one.
https://tenant.sharepoint.com/News/_api/web/lists/getbytitle('pages')/items('1234')
Check the article here: Demonstrates how to like/unlike resource via SharePoint REST API

Instagram ?__a=1&max_id=<end_cursor> isn't working for public user feeds

I've been using Instagram's undocumented API https://www.instagram.com/<user>/?__a=1 to get a public user feed.
I was also able to get multiple pages via their max_id query parameter like so: https://www.instagram.com/<user>/?__a=1&max_id=<end_cursor>
end_cursor = json_response.graphql.user.edge_owner_to_timeline_media.page_info.end_cursor
(yes, "has_next_page" is true)
They had a recent change to their JSON format and I think they might have broken other functionality.
The "end_cursor" is still there but when I use it I just get back the same Instagram posts as if I wasn't using it.
Just to make sure I'm clear, my issue is that the max_id=<end_cursor> doesn't seem to work anymore for a public user feed. I can still get the first 12 posts, but no more after that.
Anyone else seeing this problem?
here's a JSFiddle example of what I mean:
https://jsfiddle.net/LLsg91ja/33/
04-14-2018 - NO LONGER WORKING - INSTAGRAM DEPRECATED THE '?__a=1' & '?query_id=17888483320059182' - THIS NO LONGER WORKS!
Okay take a look at this for media pagination:
https://instagram.com/graphql/query/?query_id=17888483320059182&id=<user_id>&first=12&after=<end_cursor>
This returns:
['data']['user']['edge_owner_to_timeline_media']['page_info']['end_cursor']
And Media:
['data']['user']['edge_owner_to_timeline_media']['edges']
the 'query_id' is static now so just use: 17888483320059182
'id' is the "instagram user id" so you have to use ?__a=1 to grab ['graphql']['user']['id']
'first' is the number of photos you desire returned. Just use 12 to keep the media return the same.
'after' is the new 'max_id' for use ['data']['user']['edge_owner_to_timeline_media']['page_info']['end_cursor']
I'll test more and respond later.
Responding Later:
It is believed 'pagination' using ?__a=1 has been deprecated. If true then there is no answer which can solve the op's direct question using ?__a=1 for Instagram pagination.
But the code provided in this answer will provide the pagination of Instagram media which does provide the results the op was seeking.
The answer incorporates the 'instagram graphql api' which is the current api (and not the json ?__a=1 hack) so this answer should provide some stability for now.
As used on my live site:
Grab the id=<instagram_user_id> prior the Instagram media request:
profile = https://www.instagram.com/<instagram_username>/?__a=1
media = https://instagram.com/graphql/query/?query_id=17888483320059182&id=<profile['graphql']['user']['id']>&first=12&after=<end_cursor>
You can use this: ?__a=1&page=3

Pinterest API get statistic for URL

I am trying to find a way to get statistic for the URL from Pinterest API.
Like facebook graph API: URL Object
Or linked in countserv endpoint:
https://www.linkedin.com/countserv/count/share?format=json&url=https://www.linkedin.com/pulse/breaking-5-major-boolean-syntax-changes-irina-shamaeva
I know it is possible because this site is returning the number of pins for given url:
https://www.sharedcount.com/#url=https%3A%2F%2Fwww.facebook.com%2F
Does anyone know how to get these data from Pinterest API?
There is no officially supported way to do this with the developer API. That said, the widgets use this for the count bubbles using this API
https://widgets.pinterest.com/v1/urls/count.json?url=<url>.
I wouldn't depend on it for anything important tho since it is unsupported and can change/be removed at any time.
You can get the number of pins calling this url
http://api.pinterest.com/v1/urls/count.json?callback=&url=http://stylehatch.co
It will return an object like this:
({"count": 0, "url": "http://stylehatch.co"})

Query a user's "Now Playing" in iTunes?

I am trying to create an application similar to the last.fm scrobbler. but geared specifically to a certain artist. I'd like to be able to call the album the user is currently playing in tunes and based on the first 10 numbers of the album (should be a date i.e. "1999-05-10") queue up either a website or specific information regarding that date. If anyone can even begin to help me with this it would be greatly appreciated. I signed up with Apple's SDK but haven't been able to get a really clear answer on this.
I know it all starts with something like this:
var iTunesApp = WScript.CreateObject("iTunes.Application");
iTunes.App.CurrentTrack ( [out, retval] IITTrack ** iTrack )
but don't feel like I'm getting anywhere. Again any help would be greatly appreciated.
To get the album containing the current track, use the CurrentTrack.Album property of the iTunes.Application object:
var iTunes = WScript.CreateObject("iTunes.Application")
var album = iTunes.CurrentTrack.Album;
var date = album.substr(0, 10);
...
Tip: A great way to learn the available properties and methods of the iTunes COM object is to use some ActiveX/COM/OLE object browser, e.g. Visual Studio's Object Browser, to explore the iTunes type library (contained in the iTunes.exe file).

How to get the URI of a playlist creating it inside the spotify app with the spotify apps API?

I have read this question: How to create a playlist and get the URI of it in a spotify apps API?
But I was wondering if now it's possible to do it, or if you can give me a solution, I really need the URI, could I create a public Playlist or sth similar? I need that to create a App similar to soundrop :)
Thank you a lot
Sara
I believe it is possible today. The CoffeeScript example below works to me
sp = getSpotifyApi 1
models = sp.require 'sp://import/scripts/api/models'
exports.exports.init = ->
playlist = new models.Playlist()
console.log "The temporary playlist is " + playlist.uri