Download / backup all soundcloud user data - backup

I tried searching for a tool that would download all data related to a soundcloud user (uploaded tracks, likes/collection, reposts, playlists, comments, groups etc), backing it up locally, but haven't had luck so far. The user data format is not crucially important, and could be something like XML or JSON. I guess it wouldn't be hard to create it using their API, but I thought it's strange there's no tool like that already, so I wanted to ask here first.

Not a complete answer, but I'll just gather here a few bits of information that might be useful to somebody eventually. Based on this article https://helgesverre.com/blog/fetch-info-from-soundcloud-api/
First you need to register an app here, where you'll get your client id
http://soundcloud.com/you/apps/new
$clientid = "*******"; // Your API Client ID
$userid = "****"; // ID of the user you are fetching the information for
$username = "*****";
// build our API URL
$url = "http://api.soundcloud.com/resolve.json? url=http://soundcloud.com/{$username}&client_id={$clientid}";
$user_json = file_get_contents($url);
$tracks_url = "http://api.soundcloud.com/users/{$userid}/tracks.json?client_id={$clientid}";
$tracks_json = file_get_contents($tracks_url);
$playlists_url = "http://api.soundcloud.com/users/{$userid}/playlists.json?client_id={$clientid}";
$playlists_json = file_get_contents($playlists_url);
$followings_url = "http://api.soundcloud.com/users/{$userid}/followings.json?client_id={$clientid}&page_size=200"; // 200 is max
$followings_json = file_get_contents($followings_url);
$followers_url = "http://api.soundcloud.com/users/{$userid}/followers.json?client_id={$clientid}&page_size=200"; // 200 is max
$followers_json = file_get_contents($followers_url);
$reposts_url = "http://api-v2.soundcloud.com/profile/soundcloud:users:{$userid}?client_id={$clientid}&limit=1000&offset=0"; // 1000 works
$reposts_json = file_get_contents($reposts_url);

Related

Coinbase Pro - Get Account Hold Pagination Requests

With reference to https://docs.pro.coinbase.com/#get-account-history
HTTP REQUEST
GET /accounts//holds
I am struggling to produce python code to get the account holds via API pagination request and I could not find any example of implementing it.
Could you please advise me on how to proceed with this one?
According to Coinbase Pro documentation, pagination works like so (example with the holds endpoint):
import requests
account_id = ...
url = f'https://api.pro.coinbase.com/accounts/{account_id}/holds'
response = requests.get(url)
assert response.ok
first_page = response.json() # here is the first page
cursor = response.headers['CB-AFTER']
response = requests.get(url, params={'after': cursor})
assert response.ok
second_page = response.json() # then the next one
cursor = response.headers['CB-AFTER']
# and so on, repeat until response.json() is an empty list
You should properly wrap this into helper functions or class, or, even better, use an existing library and save dramatic time.

twitter stream API track all tweet posted by user who registered in twitter application

I am creating the application which need to track all tweets from user who registered to my application, i tried to track those with streaming API , there are public API, user API , and site API,
in those API it just have an option to follow the user ID by add the comma separated user ID
https://dev.twitter.com/streaming/overview/request-parameters#follow
but i think it is not flexible, if there are a new user registered , i need to rebuild the HTTP request , and also if there are so many users try to listen this stream and query will be so long,
it will be
https://stream.twitter.com/1.1/statuses/filter.json?follow=[user1],[user2],[user3]........[userN],
i afraid the query wont fit, i just need a parameter to filter all user who registered in my application such as, for example.
https://stream.twitter.com/1.1/statuses/filter.json?application=[applicationID]
but i think twitter dev does not provide it
so, is there any way to filter stream by application ID?
I didn't see anything like tracking by application id. If your query become too complex (too many follows/keywords), public streaming api will reject it,
and you can't open more than 2 connections with user stream. So, last solution is using Site Stream, -> you can open as many user connections as you have users registered to your app.
BUT the docs says :
"Site Streams is currently in a closed beta. Applications are no
longer being accepted."
Contact twitter to be sure
Arstechnica has a very interesting article about it. Take a look at this code and the link in the end of this post
If you are using python pycurl will do the job. Its provides a way to execute a function for every little piece of data received.
import pycurl, json
STREAM_URL = "http://chirpstream.twitter.com/2b/user.json"
USER = "YOUR_USERNAME"
PASS = "XXXXXXXXX"
userlist = ['user1',...,'userN']
def on_receive(self, data):
self.buffer += data
if data.endswith("rn") and self.buffer.strip():
content = json.loads(self.buffer)
self.buffer = ""
if "text" in content and content['user'] in userlist:
#do stuff
conn = pycurl.Curl()
conn.setopt(pycurl.USERPWD, "%s:%s" % (USER, PASS))
conn.setopt(pycurl.URL, STREAM_URL)
conn.setopt(pycurl.WRITEFUNCTION, on_receive)
conn.perform()
You can find more information here Real time twitter stream api

Saving information from ios app to web server (POST JSON)

The problem i am having is that i am unable to so save information from my ios application to my web server, I am currently app to retrieve the data using JSON and parsing that data.
I have written the php code for the request and it is stored on my server:
...else
{
// updating record
$q = sprintf("update phone_book set name = '%s', phoneNumber = '%s', email = '%s', phoneNumber = '%s' where name = '%s'",
mysql_real_escape_string($_GET["name"]),
mysql_real_escape_string($_GET["phoneNumber"]),
mysql_real_escape_string($_GET["email"]),
mysql_real_escape_string($_GET["address"]));
}
However I have looked everywhere and am unable to find information on how i could use post this information from my application to the web server.
Would appreciate any help. Thanks!
Use this api for post and get calls and object mapping
https://github.com/RestKit/RestKit
This actually wasent to hard. Another option instead of using REST was to POST JSON from the iOS application sending the JSON to a site where a php file contains the code. The fixed code inside the PHP would look like:
...
$json_post = json_decode(file_get_contents ('php://input'),1);
$name = $json_post['name'];
$phone = $json_post['phone'];
$aQuery = "UPDATE phone_book SET phoneNumber = '$phone' WHERE name = '$name' ";
mysql_query($aQuery);
...
If anyone requires anymore help feel free to leave a comment. Good Luck!

AS3 Flash api not setting game category app score - acces token error

Hope it's not a very noobish question i'm asking :) -
I'm trying to set the score parameter for my app ( Game category app ) with the AS3 Flash API ( Which i see is a wrapper around JS Api ) but i keep getting the "(#15) This method must be called with an app access_token" error, i've also tried a test call with the Graph API Explorer and the result is the same.( with generated acces token of the app and copy/pasted acces token )
I've searched the permission tables and i've set both publish_actions and user_games_activity for the authentification process.
Getting works perfectly ( i can receive basic information without any problems also score information but it's just an empty array probably because it isn't set ) posting seems to be the culprit
I want to know if i'm doing something wrong ( something like there's an additional auth process necessary on my server side )
If you guys have any ideea please help this is becoming very frustrating
Thanks in advance :D
Finally found the solution.
Here is the correct AS3 code:
var data:Object = new Object();
data.score = 285;
data.access_token = APP_ACCESS_TOKEN;
var requestType:String = "POST";
Facebook.api( Facebook.getAuthResponse().uid + "/scores/" , handlePostScoreComplete, data, requestType);
You MUST get the app access token using PHP or some other client-side SDK, not the Javascript SDK because it needs the app secret.
So in PHP you must get the access token and then you can pass it to Flash:
<?php
$APPLICATION_ID = YOUR_APP_ID;
$APPLICATION_SECRET = YOUR_APP_SECRET;
$token_url = "https://graph.facebook.com/oauth/access_token?" .
"client_id=" . $APPLICATION_ID .
"&client_secret=" . $APPLICATION_SECRET .
"&grant_type=client_credentials";
$app_token = file_get_contents($token_url);
?>

3-legged-oauth and Google ContactsClient problem

legged-oauth to import a users' Google contacts in my app.
I did not find the ContactsClient library but i was using only the ContacsService and i was fetching the ContactsFeed but that resulted to not having a lot of data.
After the user allows my apps i store the auth_token key and secret so i can run a cron task to fetch contacts' updates
I am using this code atm:
google = gdata.contacts.service.ContactsService(source=GOOGLE_OAUTH_SETTINGS['APP_NAME'])
google.SetOAuthInputParameters(GOOGLE_OAUTH_SETTINGS['SIG_METHOD'],
GOOGLE_OAUTH_SETTINGS['CONSUMER_KEY'],
consumer_secret=GOOGLE_OAUTH_SETTINGS['CONSUMER_SECRET'])
access_token = gdata.auth.OAuthToken(user_oauth_token, user_oauth_secret)
access_token.oauth_input_params = google.GetOAuthInputParameters()
google.SetOAuthToken(access_token)
feed = google.GetContactsFeed()
When i try to use the contacts client
contacts_client = gdata.contacts.client.ContactsClient(
source=GOOGLE_OAUTH_SETTINGS['APP_NAME'])
feed2 = contacts_client.GetContacts(auth_token = access_token)
I get the following error (please note that the access_token is the same as above and I user 3-legged-oauth HMAC)
Actual results:
File "/Library/Python/2.5/site-packages/atom/client.py", line 108, in request
auth_token.modify_request(http_request)