Updating Spotify playlist cover image with API - api

I've found several posts looking for guidance on how to use the Spotify Add Custom Playlist Cover Image API, but no responses with examples of how to use it successfully (for example). Zero responses to a recent question about this on the Spotify developers community forum.
Has anyone actually succeeded in making this work? Can you share an example?
I'm making a PUT call to https://api.spotify.com/v1/playlists/{my playlist ID}/images with headers Accept: application/json, Content-Type: image/jpeg (I've also tried application/json), and Authorization: Bearer {token}
I've encoded my image filed with base64 and confirmed there's no preface text with image/jpeg. My question is how to actually post the encoded image data? I don't think it's part of the URL call (https://api.spotify.com/ ... /images/image=), but rather in the request body. All of my various attempts are generating a 400 error: "Bad request"
Appreciate any help out there.

Related

HERE API request returns view instead of JSON

I'm trying to use the Places (Search) API (or any HERE API for that matter) for the first time. I tried the example in this page and got this page as a response:
https://places.cit.api.here.com/places/v1/browse?app_id=YOUR-APP-ID&app_code=YOUR-APP-CODE&in=52.521,13.3807;r=2000&cat=petrol-station&pretty
I don't know what I'm missing here but, I expected to get a plain JSON/XML response (orange rectangle), like this example of the Routing (Isoline) API which outputs this to the browser:
https://isoline.route.cit.api.here.com/routing/7.2/calculateisoline.json?mode=fastest;car;traffic:disabled&jsonAttributes=1&rangetype=time&start=34.603565,-98.3959&app_id=YOUR-APP-ID&app_code=YOUR-APP-CODE&range=1800
this way I could consume the service using the JSON/XML output.
I already tried both examples above in my Spring (JAVA) app and the second one works as expected, while the first one throws error (as expected).
HERE API newbie here, help appreciated.
PS: this project app of mine is just about finding nearby POIs (e.g: gyms, coffee shops, pharmacies, cinemas, etc). So, any suggestions on what API is best to go with for this, also very appreciated.
I don't know the HERE api but from having a quick look it seems they generate your results depending on the Accept header in your http request.
By default my chrome sends this accept header:
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
If I use Postman to send the request without any Accept header or Accept: application/json it returns the json results.
If I add an Accept: text/html header to the request in Postman it sends me the PlayPen in html.
You can also see in their documentation that they use the appropriate Accept: application/json
I suggest you use Postman to test and play with the API's.

JC Decaux HTTP API Request with Hurl.it

I would like to get data about city bikes - Dublin bikes- a bike sharing scheme run by JC Decaux. The information is available in real time from their website via an API. I have never gotten information from an API and cannot seem to work it.
I am using hurl.it just to check the structure of what I am requesting. I am attempting to get a list of the stations as denoted here: (https://developer.jcdecaux.com/#/opendata/vls?page=dynamic)
With this HTTP request:
GET https://api.jcdecaux.com/vls/v1/stations HTTP/1.1
Accept: application/json
I have put
https://api.jcdecaux.com/vls/v1/stations&apiKey={apikey} HTTP/1.1
into the "Destination" field. and "Accept" and "application/json" into the two "Header" fields.
I have tried many variations of this and nothing is giving me anything other than a 404 Not Found response. I am using an actual key for the api key after signing up.
Am I using this hurl.it site correctly?
First you need to get an API Key. Go to
https://developer.jcdecaux.com
to get one.
You can use your key in the URL like so: https://api.jcdecaux.com/vls/v1/stations?contract=dublin&apiKey=yourapikey

Archive Direct Messages from Twitter

Is there any way to download the own direct messages to archive them?
The Twitter API limits the call to the latest 200 DMs, which cannot download a full archive for longer conversations.
The official Twitter Archive seems not to contain the messages at all. And most thirdparty services (which you might not want to let them access your messages anyway) will be using the api and the best they can do is to poll often enough not to miss the 200 DM limit.
Is there any other way to get the messages from twitter? Scrolling back on the site seems to work, but they always load older messages in small steps and copy&paste from there gives an rather ugly result, too.
It does not need to full twitter-api information, just handle, time and message (maybe media links, if possible) should be available.
I have created a tool (https://github.com/Mincka/DMArchiver) to download my direct messages, with the ability to also download the uploaded images, videos and GIFs (as MP4).
Because it does not rely on the API, it is possible to download more than 200 messages. The script just simulate the "scrolling method" described by dimethylarginine and parse the result.
The main idea is to make requests in loop by calling the following URL with a valid auth_token cookie value for the authentication and parse the json response:
https://twitter.com/messages/with/conversation?id=1337&max_entry_id=1337
The max_entry_id value is not required for the first request. You need to use the value of the min_entry_id variable in the response as the new max_entry_id in each subsequent iteration to get the next 20 older tweets. When max_entry_id is not in the json response, you are at the begin of the thread.
Some headers are also required to get a proper response from Twitter:
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:47.0) Gecko/20100101 Firefox/47.0'
'Accept': 'application/json, text/javascript, */*; q=0.01'
'X-Requested-With': 'XMLHttpRequest'
Currently, the output of the tool is only available as an IRC-like conversation but I may add other output styles in the future (HTML, JSON, XML...).
Sorry to bring this thread back to life, but I've been having a look at this too. There are no third-party apps that can do this (as far as I'm aware) but having had a look at the source code of Twitter, it seems like with some fiddling I MIGHT be able to get them downloaded. My 'research' has shown that when you scroll up, it uses JS to load the tweets above it, using a call similar to the API. If you look through Chrome's network log you should be able to see where it gets called and the URL of the call. One can't access this through a browser, but I'll let you know if I get any further.
Sorry this isn't much of an answer yet - I'm just posting this so I can update it and not forget to do it.
Update - 10/05/2016 - I've managed to download all of my Twitter DMs. It is not elegant AT ALL, but it works. It involves leaving your computer on overnight, with the middle mouse button clicked to scroll up your DMs. Once theat has been done (it's reached the first DM), you can download the webpage and with it your DMs. This uses a lot of memory, so be careful! I am working on parsing the HTML now so it is more readable the the soup it is currently.

Understanding the Reddit API - URL vs headers vs body

Here's the API.
This is my first time working with web APIs so bear with me. Where do the name-value pairs listed under each call belong in my HTTP request? Do they go in the URL, the headers, or the body? Is it different depending on if it's a GET request or a POST?
Are the answers to these questions true in general, i.e. for any web API?
Where do the name-value pairs listed under each call belong in my HTTP request?
In a GET, they're in the URL's query string. in a POST, they're in the request body. Headers never contain request parameters, but things like Content-length do control them, a bit. You might also run across JSON in a POST body (I can't remember if reddit does this). This is not reddit-specific, and is standard HTTP.

POSTing to web service API in Objective C?

I'm writing one of my first apps for consuming a web service in Objective C, it's a Lighthouse API client. I'm able to execute all the GETs and XML parsing correctly and quickly, but I'm having extreme trouble trying to create a new ticket via POST (http://lighthouseapp.com/api).
I'm using ASIHTTPRequest.
I tried including the parameters on the URL (i.e. POST /projects/#{project_id}/tickets.xml?title=boo).
I've tried putting the ticket XML in the request body.
<ticket><title>boo</title></ticket>
Nothing is working. (server always sends a response back saying it needs a title) I'm very new to web services - am I missing something obvious?
I had a quick look at the Lighthouse API and here's how you go about creating a new ticket.
Request URL is http://{yourCustomURL}.lighthouseapp.com/projects/{ProjectID}/tickets.xml where {ProjectID} is a 5 digit number - in my case 72945.
Method is POST
Content type should be set to application/xml
Body should be in the format below. All fields are optional so I only included the title
<ticket> <assigned-user-id type="integer"></assigned-user-id> <body></body> <milestone-id type="integer"></milestone-id> <state></state> <title>Testing new ticket creation</title></ticket>
(sorry about the formatting of the code above, SO doesn't seem to like XML formatted code somehow?
This worked for me with a new ticket created under projectID 72945 - response received was 201 Created
If you want to make sure your POST request is working before diving into ASIHTTPRequest, download a Firefox add-on called POSTER from here. This will allow you to send an authenticated post request with all the fields above. Once you get that working, it should be a piece of cake to get ASIHTTPRequest to do the same.