How can I get a track ID from a track URL using the SoundCloud API?
You didn't specify a language in your question, so I'm just going to provide a high-level answer.
Use the resolve endpoint. I'm using this URL as an example:
https://soundcloud.com/msmrsounds/ms-mr-hurricane-chvrches-remix
HTTP GET: https://api.soundcloud.com/resolve.json?url=https%3A%2F%2Fsoundcloud.com%2Fmsmrsounds%2Fms-mr-hurricane-chvrches-remix&client_id=[your_client_id]
The resulting JSON:
{
"status": "302 - Found",
"location": "https://api.soundcloud.com/tracks/147986343.json?client_id=[YOUR client_id]"
}
That numerical value is the track_id. You can just stop here or hit that endpoint you just got back for more information:
{
"kind": "track",
"id": 90787841,
"created_at": "2013/05/05 00:15:40 +0000",
"user_id": 7853935,
"duration": 188333,
"commentable": true,
"state": "finished",
"original_content_size": 35031144,
"last_modified": "2014/09/30 05:53:10 +0000",
"sharing": "public",
"tag_list": "MSMR CHVRCHES \"Secondhand Rapture\" Remix Hurricane",
"permalink": "ms-mr-hurricane-chvrches-remix",
"streamable": true,
"embeddable_by": "all",
"downloadable": true,
"purchase_url": null,
"label_id": null,
"purchase_title": null,
"genre": "",
"title": "MS MR - Hurricane (CHVRCHES remix)",
"description": "MS MR - Hurricane (CHVRCHES remix)\r\n\r\n\r\n",
"label_name": "",
"release": "",
"track_type": "",
"key_signature": "",
"isrc": "",
"video_url": null,
"bpm": null,
"release_year": null,
"release_month": null,
"release_day": null,
"original_format": "wav",
"license": "all-rights-reserved",
"uri": "https://api.soundcloud.com/tracks/90787841",
"user": {
"id": 7853935,
"kind": "user",
"permalink": "msmrsounds",
"username": "MSMR",
"last_modified": "2014/08/04 09:03:56 +0000",
"uri": "https://api.soundcloud.com/users/7853935",
"permalink_url": "http://soundcloud.com/msmrsounds",
"avatar_url": "https://i1.sndcdn.com/avatars-000037198343-2lptmy-large.jpg?86347b7"
},
"permalink_url": "http://soundcloud.com/msmrsounds/ms-mr-hurricane-chvrches-remix",
"artwork_url": null,
"waveform_url": "https://w1.sndcdn.com/56LCadzDEBZn_m.png",
"stream_url": "https://api.soundcloud.com/tracks/90787841/stream",
"download_url": "https://api.soundcloud.com/tracks/90787841/download",
"playback_count": 1672227,
"download_count": 18494,
"favoritings_count": 20426,
"comment_count": 464,
"attachments_uri": "https://api.soundcloud.com/tracks/90787841/attachments",
"policy": "ALLOW"
}
Since the SoundCloud API is indefinitely not accepting new registrations, here's one alternative solution. This URL will provide you with a wide/short embedded player:
https://w.soundcloud.com/player/?url= + URL of track
Example: https://w.soundcloud.com/player/?url=https://soundcloud.com/chrisbjerken/picking-up-the-pieces
This works for both a single track or a playlist.
So my final code looks like this. Thank you guys for the help to get this working.
include_once('../Services/Soundcloud.php');
$client = new Services_Soundcloud('CLIENT_ID', 'CLIENT_SECRET');
$track_url=$_POST['trackurl'];
$track_url=str_replace("https://soundcloud.com/USERNAME/","",$track_url);
$track = json_decode($client->get("tracks/".$track_url));
$track_id=$track->id;
echo $track_id;
In The Meantime Writing This Answer The CLIENT_ID Is Close
Due to the high amount of requests recently received, we will no longer be processing API application requests at this time. We are working to re-evaluate our process to make it more efficient.
See Here
I Solved This Issue With My Laravel Project Like This
first I Made This Function To Get The Real Content
public function getLessonUrl($lessonId = null)
{
//Get the SoundCloud URL
$validUrl = 'https://soundcloud.com/al-hazme';
$result = stripos($lessonId, $validUrl);
if (strpos($lessonId, $validUrl) !== false) {
//Get the JSON data details with embed code from SoundCloud oEmbed
$getValues = #file_get_contents('http://soundcloud.com/oembed?format=js&url=' . $lessonId . '&color=%234274e3&auto_play=false&hide_related=true&show_comments=false&show_user=false&show_reposts=false&show_teaser=true&show_artwork');
if ($getValues === false) {
return 'حدث خطأ اثناء تحميل الدرس نرجو منك التأكد من اتصال الانترنيت لديك او حدث الصفحة';
}
//Clean the Json to decode
$decodeiFrame = substr($getValues, 1, -2);
//json decode to convert it as an array
$jsonObj = json_decode($decodeiFrame);
//echo $jsonObj->html;
$lessons = str_replace('height="400"', 'height="90"', $jsonObj->html);
return $lessons;
} else {
return 'لايوجد استماع لهذا الدرس';
}
}
Then I Made Another Function To Crap The Id Using Str Facade Methods
use Illuminate\Support\Str;
public function soundCloudId($url) {
$do = $lesson->getLessonUrl($lesson->url_link);
$getTrickId = Str::after($do,'tracks%2F');
$substr = Str::substr($getTrickId,0,9);
echo $substr = // 367893857
}
It May Help Or Give You Clue
I know this is kinda late but i faced the same issue yesterday and found a new (undocumented) endpoint that you can use.
https://api-widget.soundcloud.com/resolve?url=SOUNDLCOUD_URL&format=json&client_id=CLIENT_ID
You can find your CLIENT_ID by looking at the Network Inspector in the DevTools and select the XHR filter while browsing the SoundCloud website.
I think this is sufficient until the official APIs are usable again.
Related
I am having API and testing in Postman. I can able test for one page, but not sure how to test other pages. Basically, wanted to do pagination in Postman.
Here is my response from the Postman API
{
"patient_stats": [
{
"last_appointment_date": "2022-09-14T11:30:00.000+01:00",
"last_exam_date": "2022-09-14T11:15:00.000+01:00",
"last_scale_and_polish_date": "2022-09-14T11:30:00.000+01:00",
"next_appointment_date": "2022-09-28T16:15:00.000+01:00",
"next_exam_date": "2023-09-20T16:15:00.000+01:00",
"next_scale_and_polish_date": "2023-09-20T16:30:00.000+01:00",
"created_at": "2020-07-28T16:25:04.762+01:00",
"updated_at": "2022-09-14T11:52:46.144+01:00",
"total_paid": "157.5",
"total_invoiced": "157.5",
"last_cancelled_appointment_date": "2022-11-23T12:30:00.000+00:00"
},
{
"last_appointment_date": "2006-11-02T12:30:00.000+00:00",
"last_exam_date": null,
"last_scale_and_polish_date": null,
"next_appointment_date": null,
"next_exam_date": null,
"next_scale_and_polish_date": null,
"created_at": "2020-07-31T01:10:10.733+01:00",
"updated_at": "2020-07-31T01:46:42.329+01:00",
"total_paid": "0.0",
"total_invoiced": "0.0",
"last_cancelled_appointment_date": null
}
],
"meta": {
"total": 13616,
"current_page": 1,
"total_pages": 545
}
}
It shows total 545 pages. Not sure how to loop second page in Postman.
I tried to give the current_page = 2 in the params. But it's not showing second page
Can anyone advise how to test in Postman?
Each API is different, the naming changes depending on how it was developed.For example, you can try just "page" instead of "current_page". I usually used it as "page".
?page=2
I'm asking this question on SO, since LinkedIn support is officially moved here.
I'm receiving HTTP 500 response from LinkedIn API endpoint while trying to create a share. This happens sporadically, but it is a quite often event last week or two. The weird part is that the share being created successfully.
Please advise. Could it be caused by spiking users activity on social media due to COVID19?
For the reference, here is request body POST-ed to https://api.linkedin.com/v2/shares (real ids are replaced).
{
"owner": "urn:li:organization:111111",
"text": {
"text": "Text text text"
},
"content": {
"contentEntities": [
{
"entity": "urn:li:digitalmediaAsset:111111"
}
],
"shareMediaCategory": "IMAGE"
},
"distribution": {
"linkedInDistributionTarget": {
"connectionsOnly": false,
"visibleToGuest": true
}
}
}
Response:
{
"message": "Internal Server Error",
"status": 500
}
I have a JSON data file which has data like
{
"Status": "Pending",
"role": "manager",
"client": "android",
"user": "test#abc.com",
"eTyres":
{
"Wheels": {
"title": "Alloy Wheel",
"value": "Yes"
}
}
}
Firstly, I want to read this data and when Wheels.value == Yes then I want to hit an API else hit another API
Also, I would like to know how i can pass multiple parameters in post request or from the file.
Post request data is as follows:
title:Alloy_wheel__Info
part:acCooling
partTitle:AC Cooling
partValue:No
Above data i'm passing through "form-data" in postman.
Thanks in advance
Your question is hard to understand and I will assume that you want to loop over some given JSON array and do some actions. Sounds like you are not "testing" and mis-using Karate !
To loop over a JSON array, use call. Refer the docs: https://github.com/intuit/karate#data-driven-features
To do conditionals, read this part of the documentation: https://github.com/intuit/karate#conditional-logic
To do "form-data" read this: https://github.com/intuit/karate#form-field
* def data = { "Status": "Pending", "role": "manager", "client": "android", "user": "test#abc.com", "eTyres": { "Wheels": { "title": "Alloy Wheel", "value": "Yes" } } }
* eval data.eTyres.Wheels.value == 'Yes' ? karate.call('api1.feature') : karate.call('api2.feature')
How to implement api1.feature and api2.feature is a homework for you. Keep in mind that in both you will still have access to the data variable. And please read the docs and examples !
I don't know if I'm really confused or missing something but I can't find my Etsy API key anywhere.
I have created a new application but all it comes up with is KEYSTRING and Share secret.
I have tried to used the KEYSTRING value in
https://openapi.etsy.com/v2/users/etsystore?api_key=YOUR_API
but comes up with the wrong user or nothing at all.
Am I looking in the wrong place as Im starting to pull my hair out
Matt
Just follow the link: https://www.etsy.com/developers/register
Fill fields and create new App.
Profit! After that you'll see API key.
It worked for me by using just the "Keystring" value that i received while creating the app. The url looks like this -
https://openapi.etsy.com/v2/users/etsystore?api_key=my_keystring_value
and the response that I got was -
{
"count": 1,
"results": [
{
"user_id": xxxxxx,
"login_name": "EtsyStore",
"creation_tsz": 1282269739,
"user_pub_key": {
"key": "-----BEGIN PUBLIC KEY-----xxxx-----END PUBLIC KEY-----",
"key_id": 21832645947
},
"referred_by_user_id": null,
"feedback_info": {
"count": 3063,
"score": 100
}
}
],
"params": {
"user_id": "etsystore"
},
"type": "User",
"pagination": {}
}
I guess it could be some temporary issue.
Please make sure that the call you are using does not require an OAuth verification.
If the call does not require the Oauth verification, the KEYSTRING will be acting as the application key and can be passed with the URL for the results.
Shamelessly stolen from this ( https://groups.google.com/forum/#!topic/instagram-api-developers/tRfU444ZyhU ) thread as I have the exact same issue and hoping for better responses here.
Long story short, a few hours ago this was working, now it isn't.
The test platform can be found at both from my website and https://apigee.com/console/instagram
Sending https://api.instagram.com/v1/tags/türkiye/media/recent (careful with the "ü")
result: {
"meta": {
"error_type": "OAuthParameterException",
"code": 400,
"error_message": ""client_id" or "access_token" URL parameter missing. This OAuth request requires either a "client_id" or "access_token" URL parameter."
}
}
Sending https://api.instagram.com/v1/tags/turkiye/media/recent (now with "u")
result: {
"pagination": {},
"meta": {},
"data": [
{},
{},
{},
{},.. .. .. ... and so on
Sending https://api.instagram.com/v1/tags/türkiye/media/recent?client_id=7176aa6ef2fd47fd9cb373a5354bd30f ("ü" again and this time manually attached client_id)
result: {
"meta": {
"code": 200
},
"data": {
"media_count": 1471127,
"name": "t"
}
}
This time I'm getting the name as "t". It seems the query is broken just before the "ü" letter which is UTF-8 (Turkish if needed).
This is a bug on Instagram-side. There's an open discussion on Instagram Developers Google group. Although, from what I've seen in my application, the bug now resolve.