How to get list of podcast episodes from an album (iTunes Search API) - itunes-search-api

I'm trying to obtain the list of podcasts episodes from the iTunes Search API. I'm able to make a call to the API and get back all podcast albums based on a search term:
https://itunes.apple.com/search?media=podcast&term=nerdcast
This returns the following json (cropped):
{
"resultCount": 20,
"results": [
{
"wrapperType": "track",
"kind": "podcast",
"collectionId": 381816509,
"trackId": 381816509,
"artistName": "Nerdcast",
"collectionName": "Nerdcast",
"trackName": "Nerdcast",
"collectionCensoredName": "Nerdcast",
"trackCensoredName": "Nerdcast",
"collectionViewUrl": "https://itunes.apple.com/us/podcast/nerdcast/id381816509?mt=2&uo=4",
"feedUrl": "http://jovemnerd.com.br/categoria/nerdcast/feed/",
"trackViewUrl": "https://itunes.apple.com/us/podcast/nerdcast/id381816509?mt=2&uo=4",
"artworkUrl30": "http://a5.mzstatic.com/us/r30/Podcasts/v4/e1/95/35/e1953536-8437-834e-eac8-01147ae11c9e/mza_3422052630315608394.30x30-50.jpg",
"artworkUrl60": "http://a4.mzstatic.com/us/r30/Podcasts/v4/e1/95/35/e1953536-8437-834e-eac8-01147ae11c9e/mza_3422052630315608394.60x60-50.jpg",
"artworkUrl100": "http://a1.mzstatic.com/us/r30/Podcasts/v4/e1/95/35/e1953536-8437-834e-eac8-01147ae11c9e/mza_3422052630315608394.100x100-75.jpg",
"collectionPrice": 0,
"trackPrice": 0,
"trackRentalPrice": 0,
"collectionHdPrice": 0,
"trackHdPrice": 0,
"trackHdRentalPrice": 0,
"releaseDate": "2014-05-16T12:12:00Z",
"collectionExplicitness": "notExplicit",
"trackExplicitness": "notExplicit",
"trackCount": 301,
"country": "USA",
"currency": "USD",
"primaryGenreName": "Society & Culture",
"radioStationUrl": "https://itunes.apple.com/station/idra.381816509",
"artworkUrl600": "http://a2.mzstatic.com/us/r30/Podcasts/v4/e1/95/35/e1953536-8437-834e-eac8-01147ae11c9e/mza_3422052630315608394.600x600-75.jpg",
"genreIds": [
"1324",
"26"
],
"genres": [
"Society & Culture",
"Podcasts"
]
},
.....
I'd like now to get all episodes from that first result. I've tried to do a lookup request using the collectionId, but it just returns back the same output as above instead of all podcasts from that collection.
https://itunes.apple.com/lookup?id=381816509&entity=podcast
From reading the documentation and some other posts this is how I believe it should work, but it doesn't. Is anyone able to help me out? Thanks.

I think what you need to do is to take that feed URL and get the tracks from there directly
"feedUrl": "http://jovemnerd.com.br/categoria/nerdcast/feed/",
I suspect that the iTunes search API documentation and implementation contain caveats that are not written clearly out.

For me, this works. I use this code:
https://github.com/ijanerik/PHP-iTunes-API/blob/master/README.md
foreach($results as $item){
$url = $item->feedUrl;
}
$xml = simplexml_load_file($url) or die("feed not loading");
print_r($xml);

Related

Having an issue with Dialogflow API WebhookResponse V2 for Actions for Google

I'm testing Actions for Google, so I created some simple Sinatra application which looks something like:
require 'sinatra'
require 'json'
post '/google_assistant_api' do
content_type :json
case intent_name
when "input_welcome"
decorated_response
when "Recipe name"
basic_card
end
end
private
def decorated_response
{
source: "test source",
speech: "speech",
display_text: "something"
}.to_json
end
def intent_name
parsed_request["queryResult"]["intent"]["displayName"]
end
def parsed_request
#parsed_request ||= JSON.parse(request.body.read)
end
def basic_card
{
"fulfillmentText": "ACTIONS_ON_GOOGLE",
"fulfillmentMessages": [
{
"platform": "PLATFORM_UNSPECIFIED",
"text": {
"text": [
"string text"
]
},
"image": {
"imageUri": "https://avatars3.githubusercontent.com/u/119195?
s=400&v=4"
},
"basicCard": {
"title": "title string",
"subtitle": "subtitle",
"formattedText": "formatted text",
"image": {
"imageUri": "https://avatars3.githubusercontent.com/u/119195"
},
"buttons": []
}
}
],
"source": "source string"
}.to_json
end
Please note that I'm using V2 of the API and testing using google assistant:
I tried many other response formats based on https://gist.github.com/manniru/f52af230669bd3ed2e69ffe4a76ab309 with no luck. I keep getting:
Sorry! there was no response from the Agent. Please try later.
Is there anyone who tried non nodejs response with luck? I would appreciate any sample response as the simple response seems to be working, however as for the basic card I'm having no luck.
Dialogflow's v2 API uses a different format for webhook requests and responses which is documented here:
Dialogflow v2 Webhook Request
Dialogflow v2 Webhook Response
It appears that your code is using the old format.

How to get code coverage percentage for latest build from TFS 2017u2 using PowerShell & REST API

Using PowerShell, how can I query Team Foundation Server 2017 Update 2 (on-premises) to get the code coverage percentage metric from the latest completed gated check-in?
I've not found a clear API call to use in the MS reference documentation. In the web interface, I can see in the dashboard for a given completed build the percentage value and a link to download the entire Visual Studio coverage file. I don't want the file, though. I just want to make an API call and get the percent coverage value for the last successful build of a given definition.
Unfortunately, the docs for VSTS's REST API are down right now, but this should get you started (pulled from Google's Cache).
This endpoint handles everything related to Tests and Code Coverage.
https://{instance}/DefaultCollection/{project}/_apis/test/codeCoverage?api-version={version}[&buildId={int}&flags={int}]
Provide values for the following and then run this Invoke-RestMethod to get the data back.
$Instance = 'fabrikam-fiber-inc.visualstudio.com' #your URL here
$ProjectName = #YourProjectNameHere
$buildID = #YourBuildIDHere
$version = '2.0-preview'
Invoke-RestMethod -uri https://$Instance/DefaultCollection/$ProjectName/_apis/test/codeCoverage?api-version=$version
Here's a sample response you can get back:
Status code: 200
{
"value": [
{
"configuration": {
"id": 51,
"flavor": "Debug",
"platform": "Any CPU",
"uri": "vstfs:///Build/Build/363",
"project": {}
},
"state": "0",
"lastError": "",
"modules": [
{
"blockCount": 2,
"blockData": "Aw==",
"name": "fabrikamunittests.dll",
"signature": "c27c5315-b4ec-3748-9751-2a20280c37d5",
"signatureAge": 1,
"statistics": {
"blocksCovered": 2,
"linesCovered": 4
},
"functions": []
}
],
"codeCoverageFileUrl": "..."
}
],
"count": 1
}
It looks like blocksCovered and livesCovered are probably the closest you'll get from the API. Let me know if you need some help or get stuck. Eventually, the docs will be back online at this URL.

Difference between start_nickname and start_address

Can somebody explain me what is the difference between start_nickname and start_address in https://developer.uber.com/docs/riders/references/api/v1.2/requests-post ? Maybe in form of examples? I don't know which one to use to provide street and city info.
start_nickname in POST /requests is the label used for the destination in the rider app when you create a request via the api. So please use start[latitude|longitude] or start_place_id to specify Start Location.
So if you try to request a ride with just start_nickname and start_address
{
"product_id": "a1111c8c-c720-46c3-8534-2fcdd730040d",
"start_nickname" : "Uber HQ",
"start_address" : "1455 Market Street, San Francisco",
"end_latitude": 37.795,
"end_longitude": -122.440,
"end_nickname" : "Embarcadero",
"end_address" : "One Embarcadero Center, San Francisco"
}
you will get a response like:
{
"fields": {
"": "Both start_latitude and start_longitude or start_place_id are
required."
},
"message": "Invalid request",
"code": "validation_failed"
}
In order to make a valid ride request you need to add:
"start_latitude": 37.776,
"start_longitude": -122.418,
Or "start_place_id" (This is the name of an Uber saved place. Only “home” or “work” is acceptable.)

Facebook GraphAPI and FQL API return different value for same URL

I trying to migrate my facebook app from FQL API (1.0) to GraphAPI (2.3) and i encounter some problems.
Main goal of my facebook application is fetching current count of likes, shares and comments for specified links (article url). (I think, something similar to How to get facebook share, like, comment count for a url with graph api only (in a non-deprecated way))
In (old) FQL API i could get this information by executing SELECT ... FROM link_stat table. ex.:
https://graph.facebook.com/fql?access_token=xxxxxxxxxxxx|yyyyyyyya&q=SELECT%20click_count%2Ccomment_count%2Ccommentsbox_count%2Clike_count%2Cshare_count%2Ctotal_count%2Cnormalized_url%20FROM%20link_stat%20WHERE%20url%20IN%20%28"http%3A//sport.wp.pl/kat%2C1715%2Ctitle%2CSwiat-pokochal-polskiego-sportowca-Mimo-ze-ledwo-dukal-po-angielsku%2Cwid%2C17449498%2Cwiadomosc.html"%29
which return information in JSON, ex.:
{
"data": [
{
"like_count": 21,
"comment_count": 0,
"click_count": 0,
"commentsbox_count": 0,
"total_count": 29,
"share_count": 8,
"normalized_url": "http://sport.wp.pl/kat,1715,title,Swiat-pokochal-polskiego-sportowca-Mimo-ze-ledwo-dukal-po-angielsku,wid,17449498,wiadomosc.html"
}
]
}
In new GraphAPI (2.3) theoretically this information is available via:
URL and /{object-id}/likes edges:
https://developers.facebook.com/docs/graph-api/reference/v2.3/url
https://developers.facebook.com/docs/graph-api/reference/v2.0/object/likes
Which return value. ex.:
{
"share": {
"comment_count": 0,
"share_count": 42
},
"og_object": {
"url": "http://sport.wp.pl/kat,1715,title,Swiat-pokochal-polskiego-sportowca-Mimo-ze-ledwo-dukal-po-angielsku,wid,17449498,wiadomosc.html",
"description": "Kibice wstrzymali oddech, dos\u0142ownie. W sali s\u0142ycha\u0107 by\u0142o tykaj\u0105c\u0105 wskaz\u00f3wk\u0119 zegara zawieszonego na \u015bcianie. Przy stole sta\u0142 Bogdan Wo\u0142kowski, nieruchomo patrzy\u0142 na \u015brodek, gdzie znajdowa\u0142a si\u0119 wysoka piramida z\u0142o\u017cona z kilku poziom\u00f3w bil i tr\u00f3jk\u0105t\u00f3w. Na jej szczycie sta\u0142 cz\u0142owiek. Mija\u0142y kolejne sekundy, napi\u0119cie ros\u0142o. Nagle \"Wizard\" wzi\u0105\u0142 kij do r\u0119ki, przymierzy\u0142, hukn\u0105\u0142 w bil\u0119, ta uderzy\u0142a w piramid\u0119 i...",
"type": "article",
"title": "\u015awiat pokocha\u0142 polskiego sportowca. Mimo \u017ce ledwo duka\u0142 po angielsku",
"updated_time": "2015-04-14T19:46:03+0000",
"id": "1055320127830544"
},
"id": "http://sport.wp.pl/kat,1715,title,Swiat-pokochal-polskiego-sportowca-Mimo-ze-ledwo-dukal-po-angielsku,wid,17449498,wiadomosc.html"
}
and
{
"1055320127830544": {
"data": [],
"summary": {
"total_count": 0
}
}
}
Unfortunately this values isn't consistent with results from FQL API .
So, my question is:
What mean each value in response, and why it is not consistent with FQL?
It seems to be a known issue with the API. You can follow this post for updates.
This post has a good explanation of how to get share counts.
Also what I have noticed is that for API version 2.1 and above, share_count in the response contains the total number of shares including the link shared directly on the Timeline by the user. For version 2.0, I think shares in the response excludes this.

Facebook API: How to get count of group members

Im working on fb app using PHP client and FQL.Looks like that fb api doesnt support this. You can get max random 500 members with FQL. But when group has more than 500 members there is no way how to get total count of members.
I need only number dont care about member details.
Anyone can help me please?
I have actually found that you cannot, it is by design apparently. I wanted to know this myself about a month ago, and found that no matter what parameters you pass in to the graph api, you can not get past the 500th member. Even if you tell it to start at number 450 and give you 200, it will give you only 450-500.
Here's me asking, and the unfortunate answer:
http://forum.developers.facebook.net/viewtopic.php?id=82134
you can use graph api 2.0 and sdk 4.0
you can use below code
$url1= "https://graph.facebook.com/".$gid."/members?limit=10000&access_token=".$_SESSION['fb_token'];
if(!extension_loaded('curl') && !#dl('curl_php5.so'))
{
return "";
}
$parsedUrl = parse_url($url1);
$ch = curl_init();
$options = array(
CURLOPT_URL => $url1,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_TIMEOUT => 10,
CURLOPT_HTTPHEADER => array("Host: " . $parsedUrl['host']),
CURLOPT_SSL_VERIFYHOST => 0,
CURLOPT_SSL_VERIFYPEER => false
);
curl_setopt_array($ch, $options);
$response_count = #curl_exec($ch);
$json_count = json_decode($response_count);
foreach ($json_count as $item_count)
{
$cnt=count($item_count);
break;
}
You can use the summary parameter which will return a total_count value.
/v2.11/{GROUP_ID}?fields=members.limit(0).summary(true)
It also works when searching for groups:
/v2.11/search?q=stackoverflow&type=group&fields=id,name,members.limit(0).summary(true)
{
"data": [
{
"id": "667082816766625",
"name": "Web Development Insiders",
"members": {
"data": [
],
"summary": {
"total_count": 2087
}
}
},
{
"id": "319262381492750",
"name": "WEB Developers India",
"members": {
"data": [
],
"summary": {
"total_count": 10240
}
}
}...
]
}
Make a query to:
https://graph.facebook.com/v2.11/{group-id}/members?limit=1500&access_token={token}
(replace {group-id} by the numeric group identification and {token} by your access token).
You will get a response like this:
{
"data": [
{
"name": "Foo bar",
"id": "123456",
"administrator": false
},
...
],
"paging": {
"cursors": {
"before": "QVFIUkwzT3FKY0JSS2hENU1NUlZAocm9GelJMcUE3S1cxWWZAPYWx1cUQxcXFHQUNGLUJnWnZAHa0tIdmpMT0U5ZAjRBLUY5Q2ZAGbmwwVTNoSHhLc1BCc2dvVTF3",
"after": "QVFIUkFoU3lYR2tXc09adkg5OGhlbHRWRk1GYkZAzQU1DalRSY05zOVl5aE1tcjRMS3lXLURaVWNMOGZArWTVxS2hPQUVGVWxhbXZAyZA0p3azVKM2hBSEp3YlpR"
}
},
"next": "https://graph.facebook.com/v2.11/123928391023981/members?access_token=EAACEdEose0cBALBDrdgLyVOjzW4mz6G3d3Yj1fTGYqygVgYq0JCDZAi0zYsY90pSSQ9hQZCn3TdwfXIAiyoXH5oUYcA4hOcCI9jztkkUhbBv9tEQ3ZBEEuHpmkm3kmgvk1HNq5mo6BM0hz8XkOLVh3twIdz83KhB9SkqxuxHeFD9GWsQqjys6XTuL2315QZD&pretty=0&limit= 1500&after=QVFIUkFoU3lYR2tXc08adkg5OGhlbHRWYk1GYkZAzQU1DalRSY05zOVl5aQ1tcjRMS3lXLURaVWNMOGZArWTVxS2hPQUVGVWxhbXZAyZA0p3azVKM1hBSEp3YlpR"
}
Then follow this algorithm:
Make a count variable with a 0 value.
Count the objects in the data array of the latest response and add the count to the count variable.
If the latest response has the next property, make a request to the URL which is the next property value and return to the step 2. Otherwise you have finished, the count of members is the count variable value.
This way is not very good because the more members there are in the group the more queries are required. I would be better to parse the number of members from the group page HTML but I can't find reliable way to do it.
Update 2017.10.19: If the Facebook API response size is more then about 345KB, Facebook returns an error: Please reduce the amount of data you're asking for, then retry your request. It is about 1997 members. So you need to set the limit request parameter to 1500 not to face the error.
Update 2018.01.26: There is a way to get a count of members using a single request: https://stackoverflow.com/a/47783306/1118709
Update 2018.01.31: After 90 days from releasing Graph API v2.12 the request will require an access token of an admin of the group. Source: Graph API docs / v2.12 changelog / 90-day breaking changes
You should do it with an FQL query on the group_member table like:
SELECT uid FROM group_member WHERE gid = <group_id> limit 500 offset 500
Example here: Is it possible / how to get number of a particular Facebook Group members (even if number of them is 500+)?