Does the lastFM api provide youtube links? - api

I am making an android application which lists trending songs. I am fetching the song details through the LastFM API. The API method I use is http://ws.audioscrobbler.com/2.0/?method=track.getInfo&api_key=YOUR_API_KEY&artist=cher&track=believe&format=json
However, this doesn't give me a link to YouTube like how LastFM does on their website. Is there any way for me to replicate that functionality? Am I supposed to use another API method that I don't know of or should i rely on something else entirely?
I did some amount of searching and I came across http://downloadmarkt.be/lastfm-musicengine/example-search.php In the search results, the YouTube links are also displayed. How is the developer achieving this?

There are no direct links to youtube videos in the last.fm API.
The website you posted searches the links directly on youtube and not on last.fm (see the javascript at the bottom of that script file).
Best solution that I've found: you do get a page song url in the last.fm API response,
<url>
https://www.last.fm/music/Anathema/_/Fragile+Dreams
</url>
That page contains the youtube url. If you open the html page, you'll see something like this in there
data-youtube-id="CsHYSvlsDWw"
data-youtube-url="https://www.youtube.com/watch?v=CsHYSvlsDWw"
Use your favorite method for parsing webpages to get that info,
$ curl -sL https://www.last.fm/music/Anathema/_/Fragile+Dreams |
hxnormalize -x 2> /dev/null |
hxselect -s '\n' -c 'a::attr(data-youtube-id) |
uniq
$ CsHYSvlsDWw
that is, you get the page, you get rid of any inconsistencies and then you select the data-youtube-id. You need to add a new line between the matches, since there seems to be two such entries on the page. Last step, you take one of the two similar results (the uniq part at then end).
Happy hacking.

Related

How to get all unread items using Feedly API

OK, either this is incredibly obvious and I'm just too dumb to see it, or it is not possible at all.
I created a Feedly developer access token and can call some end points just fine, like /profile, /categories, etc. Currently testing them with curl, but eventually will do this in Ruby.
What I can't find from the documentation (or even by Googling) is how to access all the unread entries from all my subscriptions just like I do in the Feedly app:
As far as I understand, Streams are for specific feeds. And the closest thing to the All stream, I think, is the Global Resource Id "global.all". But when I call it according to the documentation I get "API handler not found".
curl -H 'Authorization: OAuth [<MY_ACCESS_TOKEN>]' http://cloud.feedly.com/v3/user/<MY_USER_ID>/category/global.all
{"errorCode":404,"errorId":"ap5int-sv2.2018082612.1607238","errorMessage":"API handler not found"}
At some point I thought maybe Feedly just doesn't support this and went and looked at Inoreader's API documentation and it looks pretty much the same. There is no /All stream where I can pull my unread entries. So I feel like I'm missing something very obvious here.
What I am trying to do:
Basically I want to create an app for myself where I pull all my unread entries and flag the ones I'm interested in as "Read Later". This is part of a bigger workflow app that I'm working on.
You're almost there. To get a stream of all your unread articles, the syntax would be:
curl -H 'Authorization: OAuth <access token>' 'https://cloud.feedly.com/v3/streams/contents?streamId=user/<user id>/category/global.all&unreadOnly=true'
The <user id> can be obtained by the Profile API which can be found here.
The streams API is documented here.
Hope this helps.

Filter Google Custom Search Engine results by site

I have been having issues using the Custom Search Engine API while (trying to) using the functionality of its specific site search.
I have created (using the web console) a CSE and defined it to search in 2 sites:
*.ebay.com
*.amazon.com
First, when searching for the term 'pcrush' (with curl), I receive results from amazon.com and ebay.com domains, as expected. this is ok.
curl -X GET 'https://www.googleapis.com/customsearch/v1?key=<my-key>&cx=<my-cx>&q=pcrush'
When I try making the same search but limit the results to be just from a specific site, I still get results from both eay and amazon.
Here, I want to receive only the ebay.com results:
adding &as_sitesearch=ebay.com
adding &as_sitesearch=ebay.com&as_dt=i
adding &as_sitesearch=amazon.com&as_dt=e
all of the above example, when the domain is *.ebay.com or *.amazon.com
It all still returned results both from ebay.com and amazon.com
I should mention we are following the API as described here.
What am I doing wrong?
Thanks in advance.

API to GET the confluence page content via page name?

I want to CURL an API to get the contents of a confluence page using the pagename. I have an API to get the page details via pageid.
curl -u <userid>:<password> -X GET confluence-url/confluence/rest/prototype/1/content/<pageid>
But i want an API to get the same via pagename. Is that possible?
Check out confluence rest api examples
Maybe you are looking for something like this:
curl -u admin:admin -X GET "http://localhost:8080/confluence/rest/api/content?title=myPage%20Title&spaceKey=TST&expand=body.storage"
EDIT:
"title" is the name of the page
"spaceKey" is the key for your space. Confluence is organized in spaces. You can read more about spaces here
Expansions are documented here. expand specifies which elements should be expanded in the response. as stated in the documentation
If your GET returns a list of results and you don't choose to expand anything, the response is terse, displaying only a basic representation of the resource. It will, however, include a list of the expandable items for the resource.
So if you want the response to include the content of your page, then you need to expand "body.storage". If you want to expand multiple things you can seperate them with comma.

REST API for driving distance?

Is there a service that will give me the driving distance between two addresses? Apparently Google Maps API requires you to display a map, which I don't want to do (on that particular page), and I'd like to just snag the data and save it to my DB after a user submits a form, rather than waiting for JS to do it's thing.
If it's relevant, this is going into a Django app. I discovered that CloudMade offers a Python API, which is nice, except their latest dev release has a bug in it (can't use the API object), but more importantly, it's support for Canada is awful (couldn't find directions from any major city around here!).
MapQuest's Directions API is HTTP Querystring based (I'm not sure if it's entirely RESTful). Can get XML or JSON response. Just need to send it an HTTP GET Request.
http://developer.mapquest.com/web/products/open/directions-service
Use the "distance" response parameter.
I don't have a high enough reputation on SO to comment on an answer but I just wanted to be clear that contrary to the voted correct answer, Google Directions API has to adhere to the Google Maps API. If you scroll down the supplied link, you will see:
Note: the Directions API may only be used in conjunction with displaying results on a Google map; using Directions data without displaying a map for which directions data was requested is prohibited. Additionally, calculation of directions generates copyrights and warnings which must be displayed to the user in some fashion. For complete details on allowed usage, consult the Maps API Terms of Service License Restrictions.
Would it be possible to use Google Maps GDirections object? This can return the textual directions instead of the map overlay if called with a div object. From there you can use the getDistance (or getDuration) functions. You can always use an invisible div for the returns if you don't want anything to be displayed on the page.
Start here
http://code.google.com/apis/maps/documentation/examples/directions-advanced.html
http://code.google.com/apis/maps/documentation/reference.html#GDirections
And use this sample code
var map;
var directionsPanel;
var directions;
function initialize() {
directionsPanel = document.getElementById("route");
directions = new GDirections(null, directionsPanel);
GEvent.addListener(directions , "load", onGDirectionsLoad);
directions.load("from: 500 Memorial Drive, Cambridge, MA to: 4 Yawkey Way, Boston, MA 02215 (Fenway Park)");
}
function onGDirectionsLoad(){
alert(directions.getDistance().html);
}
Here is my solution:
Signup for Mapquest Developer network.
Get AppId
Open your command shell and run the following command(or use fiddler) But running it through curl will give you flexibility to automate your request
curl -X POST -H "Content-Type: application/json" -d '{locations: ["Salt Lake City, UT","Ogden, UT",],options: {allToAll: false}}' http://www.mapquestapi.com/directions/v2/routematrix?key=YOURKEYGOESHERE >> distance.txt
Save above command with all your destinations into batch or sh file.
Now grep and parse out your distance.txt file for what you need.
There are free services out there, but the quality of the data may be questionable/non-existent in areas. Be aware of licences on the data too, storing in your own DB may be a breach.
http://openrouteservice.org/
Take a look at Navteq. I used their service in developing a driving directions application about 5 years ago, and got good results. Can't speak for them lately though. I believe the best URL is Navteq Routing Service
You can use the new Google Directions API directly, without using any javascript.
http://code.google.com/apis/maps/documentation/directions/

Is it possible to retrieve Facebook Pages information like notes, photos, and videos?

I've been up and down the Facebook API as well as all over the internets looking for an answer to this question.
Has anyone seen an example of a website that displays information pulled from a Facebook Page? Is this even possible?
I've been able to run the demos provided at Trying Out Facebook Connect and the API Test Console, but I've only been able to retrieve information on users not pages.
Any help would be appreciated.
Just tried it out on the console - it does work with pages. You just have to use the page ID instead of the user ID for whatever you're trying to get.
Example:
$facebook->api_client->photos_getAlbums(5281959998,'');
This gets the photo albums of the page with ID 5281959998, which is the NY Times.
For now, it doesn't appear possible. Quote from Stream.get:
This method returns an object (in JSON-encoded or XML format) that contains the stream from the perspective of a specific viewer -- currently, a user, and in the near future, a Facebook Page.