spotify / apps-tutorial

A Spotify App that contains working examples of the use of Spotify Apps API
https://developer.spotify.com/technologies/apps/
627 stars 146 forks source link

XHR issues #2

Closed nottombrown closed 12 years ago

nottombrown commented 12 years ago

Hey, I'm setting up an app to play a themesong for each developer when we push code to github.

I have a server that I want to poll for updates, but I'm having difficulty accessing that data via the client. I'm confused as to why the following works properly when requesting data from twitter but fails when requesting from my server hosted on heroku.

xhr = new XMLHttpRequest()

# request = 'http://search.twitter.com/search.json?q=open.spotify.com%2Ftrack&include_entities=true'
request = 'http://shipify-server.herokuapp.com/'

xhr.open('GET', request)

xhr.onreadystatechange = ()->
  if (xhr.readyState != 4)
    return
  console.log xhr
  data = JSON.parse(xhr.responseText)
  handle(data)

xhr.send(null)

handle = (data)->
  console.log data
nottombrown commented 12 years ago

Resolved using socket.io

jjgonecrypto commented 12 years ago

i'm interested in that pairing - socket.io & heroku talking to a spotify app.

how has it been working so far?

nottombrown commented 12 years ago

It's been working well. Make sure that you whitelist your heroku server in the RequiredPermissions of your manifest.json

jjgonecrypto commented 12 years ago

will do. are you open sourcing the product or is it private?

nottombrown commented 12 years ago

The work in progress is open source. Check it out here: https://github.com/Grouper/shipify https://github.com/Grouper/shipify-server

Hope it's helpful, and feel free to message me outside of this issue.

jjgonecrypto commented 12 years ago

sweet - will check it out.

Play themesongs for people whenever they ship code to github.

cute. :)