Soundcloud API get only permalink_url - soundcloud

How can I get the permalink_url only of using Soundcloud API tracks?
It returns all fields.
How am I able to return only the permalink_url?
I tried this but no luck: I tried this but no luck: http://api.soundcloud.com/tracks.json?client_id=XX&q=Charlie%20Puth&limit=100&fields=permalink_url

You should be able to parse the returned JSON for the permalink_url. Something like:
var parsedJSON = JSON.parse(tracksJSON);
var permalink = parsedJSON.permalink_url;
If you have jQuery, I believe $.getJSON automatically parses the info for you as well. I hope this helps you!

Related

Getting a specific data from HTTP body response

I am sending some data to my api by post and when it successfully submitted, it will return some data and I want to access the response data.
This is what I've got from my component :
this.http.post(this.restProvider.restApiUrl+'saveDraft', draftData, options)
.subscribe(data => {
console.log(data["_body"]);
}, error => {
console.log("Oooops!");
});
The console.log(data["_body"]); will resulting this data :
{"status":"ok","data_id":"2","statusMsg":"Saved as draft"}
What I'm trying to do now is to access the value of data_id but I'm not really sure how to get it inside my component. I thought it can be accessed by something like data["_body"]["data_id"]
I think data is an object. Try this:
console.log(data._body.data_id);
console.log(data["_body"].data_id);
Finally, I solved the issue by changing the console.log(data["_body"]); to console.log(data.json().data_id);
I refer to this discussion Angular 2: How to access an HTTP response body? and tried to apply the JSON and it works.

webClient Exception in .net

I simply request(to elasticsearch) in browser fine:
in .Net, I want to post same request and expected to get json data seem in pic above, but here is the exception.:
What is the point of this failure?
Why are you calling UploadString()? Simply invoke DownloadString() for the entire URL and you'll be good to go:
var data = webc.DownloadString("http://localhost/.../ability");
Please use DownloadString method instead of UploadString:
var asd = webc.DownloadString("http://localhost:9200/dota2/_mapping/agust/field/ability");

Facebook graph api returns empty result

I am trying to pull user feeds from facebook, But the array of result i am getting is empty. The code i am using is
$jsonurl = "https://graph.facebook.com/{$user_id}/feed?limit=25&access_token={$access_token}";
$json = file_get_contents($jsonurl,0,null,null);
$user_data = json_decode($json, true);
print_r($user_data);
The result always getting is
Array ( [data] => Array ( ) )
Can anyone help me to find what the issue is?
Thanks in advance
I have tried your give code in my php code.
It is working find. Please check that the USERID which you are posting has a feed.
To test try BMW, FACEBOOK userid so you can find the feeds.
Try below url you will get its feed.
https://graph.facebook.com/BMW/feed?limit=25&access_token={$access_token}

Can someone help me with POST method in Slim Framework?

I can set a GET method in Slim to get data from my database but my problem is the POST method, i don't know how to use it correctly. I do some code like:
$app->post('/login',function() use ($app){
$inputs = json_decode($app->request()->getBody());
$result = json_encode($inputs);
return $result;
});
I wanna make a login function by POST method but this is just an example I want to show the data that have been sent in the body by json. I used Advanced Rest Client to test but the result is always "null".
I'm new to Rest and Slim Framework too. Thanks for any helpful idea !
using return doesn't do anything in terms of viewing the output within that route callback function. use print, print_r, echo, $app->response->setBody('Foo'), or $app->response->write('Foo')
in terms of the post, did you try using $data = $app->request()->post() to get your data?

How to send xml/application format in bottle?

If some one come to my url suppose /get it should give back a xml/application format in response in bottle framework. How can i do this? i am using elementree as xml generator.
Look on the official page for the cookie example and do it like this:
#route('/xml')
def xml():
response.headers['Content-Type'] = 'xml/application'
....(create the xml here)......
return xml_content_whatever