I'm trying to delete a track on soundcloud via their API. I'm using the Njasm php library for sound cloud (not an official one as I don't think they have an official one).
I can upload fine but I'm not 100% sure how to delete a track.
I have this:
$params = array("id"=>255008920);
$response = $facade->delete("/tracks", $params);
But this does not seem to delete the track.
What do I have to use (even if it's not based on the Njasm library) to delete a track?
I'm the creator of the njasm library.
First of all thanks for using it.
In regard to your question: You are calling the right method with the right parameters, but you need to call the
request()
method in the end, to invoke the API. Assumming you're authenticated.
Example:
$facade = new SoundcloudFacade($clientID, $clientSecret);
$facade->userCredentials($username, $password);
$params = ["id" => 12345];
$response = $facade->delete('/tracks')->request();
// or
$facade->delete('/tracks');
$facade->setParams($params);
$response = $facade->request();
Hope it helps.
To use delete functionality you will need to use OAuth authentication.
This might point you in the right direction
https://apigee.com/console/soundcloud?apig_cc=1
Related
I'm a php programmer but I'm new to APIs.
I would like to run a mysql query to get info from an XML document from madmimi.com.
documentation from madmimi.com says
GET http://madmimi.com/audience_lists/lists.xml will return the data I need. I've created a php file and connected to their API using
require(dirname(FILE) . '/MadMimi.class.php');
$mailer = new MadMimi('username', 'password');
but I don't understand how to use GET to connect to the URL and display the XML info?
What do I need to do?
All http api interaction is hidden to you behind their library. You can use it's methods to grab objects, like this to lists:
$mailer->Lists();
There is no complete documentation, but you can read raw code to search urls, described in API for finding appreciated methods.
You can use curl to get the response from the 3rd party api. Have a look at this answer:
https://stackoverflow.com/a/5159513/1369567
Based upon the code in answer given at that link, you may need to the code to match your request. E.g:
/* Script URL */
$url = 'http://madmimi.com/audience_lists/lists.xml';
/* $_GET Parameters to Send */
$params = array('username' => '*your api username*', 'password' => '*your api password*');
I keep getting error code 34 (Sorry, this page does not exist) when attempting to make a post request to the statuses/filter method with the abraham twitteroauth class (https://github.com/abraham/twitteroauth). Following authentication (that's working fine) my request is simple:
$filter = $twitteroauth->post('statuses/filter',array('track' => 'seo'));
I have other calls working but even when I isolate this on a separate instance of the site, I'm only receiving the "Sorry, that page does not exist" error.
Any help would be appreciated.
TwitterOAuth does not currently support the Streaming APIs. You can try the method that #JohnC suggests but I don't know if it will actually work.
Phirehose is the PHP library I recommend for use with the Streaming APIs.
The statuses/filter call uses a different URL to many of the other API calls - using stream.twitter.com instead of api.twitter.com. The library you are using appears to be hardcoded to only use api.twitter.com, so this could be the source of your problem. You can either change the URL for that call:
$twitteroauth->host = "https://stream.twitter.com/1/";
$filter = $twitteroauth->post('statuses/filter',array('track' => 'seo'));
Or if you use the full URL it will override the default (probably the best way if you make multiple calls to the $twitteroauth class):
$filter = $twitteroauth->post('https://stream.twitter.com/1/statuses/filter.json',array('track' => 'seo'));
I am collecting an access_token for facebook web app
so, I have the following:
$fb_url = "https://graph.facebook.com/oauth/authorize?type=user_agent& .
client_id=132456789&redirect_uri=http%3A%2F%2Fmysite.com .
&scope=user_photos,email,user_birthday,user_online_presence";
When I go to that URL it forwards me to:
mysite.com?access_token=5sdf5s5wrrg4e645e645
So how can I fire the URL and collect variable access_token without actually going there which obviously cannot happen... if that makes sense!
Generally speaking, you need to make a curl request programmatically and interpret the response. Practically it would be easier if you used a specialized "facebook connector" class. Did you check out Facebook's developer docs?
You could try to send a HTTP-Request manually and then work with the result
http://php.net/manual/en/httprequest.send.php
how can I fire the URL and collect variable access_token without actually going there
You can't.
You can however actually go there without sending the user's browser to that URL, if that is what you mean. You can do that using cURL, which makes that request serverside. You can then present the result to the user, or do whatever you want to do with it.
Here's how I did it - facebook sdk is daunting at times then all of a sudden it all makes stupid sense!
require '/home/***/public_html/pages/social_login/fb_lib/facebook.php';
$config = array();
$config[‘appId’] = '__APP_ID__';
$config[‘secret’] = '__SECRET__';
$facebook = new Facebook($config);
//TO GET ACCESS TOKEN
$access_token = $facebook->getAccessToken();
I am using the main soundcloud wrapper (https://github.com/mptre/php-soundcloud) to try and pull the tracks off my account onto my website. I had the whole thing working great but just by accessing a query (my username has changed and isn't as unique, so i need to change the query). So what I need to request is exactly this "https://api.soundcloud.com/users/isound604/tracks.json" and if you check in the API console you will see it returns my tracks.
My problem is that i don't know how to make this request with the wrapper. I used to use:
$string = $soundcloud->get('tracks', array('q' => 'beatmanshan', 'order' => 'created_at'));
but the new request doesn't seem to work in that function. Can anybody shed any light on this issue? Please and thank you in advance! Let me know if you need any more info.
Have you already authenticated ok using the api? To check
$my_details = json_decode($soundcloud->get('me'));
Should return your account details
If so have you tried
$string = $soundcloud->get('users/isound604/tracks', array('order' => 'created_at'));
So, I figured out how to get an access token from Google using the Zend_Oauth library in 1.10. Now lets say I want to get my contacts...
$config = array(
'consumerKey' => 'zzz',
'signatureMethod' => 'HMAC-SHA1',
'consumerSecret' => 'xxx'
);
$token = unserialize($_SESSION['GOOGLE_ACCESS_TOKEN']);
$client = $token->getHttpClient($config);
$client->setMethod(Zend_Http_Client::GET);
// $client->setParameterGet('max-results', '10000');
$gdata = new Zend_Gdata($client);
$gdata->setMajorProtocolVersion(3);
$query = new Zend_Gdata_Query('http://www.google.com/m8/feeds/contacts/default/full');
// $query->MaxResults=100;
$feed = $gdata->getFeed($query);
$feed is a lovely object with 25 contacts. But if I want to get more in a single pull, there doesn't seem to be a way of specifying max results that works.
If I uncomment client->setParameterGet it's ignored. It works if I specify $client->setUri and use $rawdata = client->request() to get the response, but then other issues crop up with handling the feed data that comes back... like getting it into GData for easy handling.
I've tried $feed = $gdata->importString($rawdata->getBody()) but while $rawdata->getBody() returns what seems to be valid XML, $feed->totalResults throws an error, while it wouldn't if I used $gdata->getFeed($query).
If I uncomment $query->MaxResults=100; use $gdata->getFeed($query) Google returns a 401 with "Unknown authorization header".
So is it possibly to specify parameters while using Zend_GData with an Oauth token? Or am I going to have to build my own requests, then use Zend_Feed (or some other XML/Feed dissector) for parsing?
I totally cannot get the whole list of contacts only 25... parameters do not seem to work using Gdata and query like this:
$http = $token->getHttpClient($oauthOptions);
$gdata = new Zend_Gdata($http, 'MY APP');
$gdata->setMajorProtocolVersion(3);
$gdata->getHttpClient()->setRequestScheme(Zend_Oauth::REQUEST_SCHEME_QUERYSTRING);
$query = new Zend_Gdata_Query('http://www.google.com/m8/feeds/contacts/default/full?max-results=10');
$query->setMaxResults(10);
$query->maxResults = 10;
$feed = $gdata->getFeed($query);
so i;m really into finding answers here as well. If either of you gets anything working. please post :-)
thanks
It's a bit tricky mixing a process meant to work with AuthSub with OAuth. I did some digging. So far I can get it to download all my contacts like this...
$client = $token->getHttpClient($config);
$client->setMethod(Zend_Http_Client::GET);
$client->setUri('http://www.google.com/m8/feeds/contacts/default/full/');
$client->setParameterGet('max-results', '10000');
$client->setParameterGet('v','3');
$bfeed = $client->request();
Looks like the primary difference between us is I specify the Feed URL in the $client->setUri('http://www.google.com/m8/feeds/contacts/default/full/'); and set my version differently. But I can get the body() property of $bfeed and it gives me 245k of XML to dissect.
My problem is that when I'm pulling down a single contact's feed via this method, I was getting an error.
I, like you, am trying to figure this out, so please reply with anything that works for you.