shibin
shibin

Reputation: 73

Samsung TV app - access external links to scrape data

recently started developing smart tv app for Samsung.

  1. I am wondering the best way to access any external link and get the data we wanted (processing HTML/DOM etc.) from the app. Planning to use ajax, is that the right way? Or is there any native Samsung API we could use which will have better performance? Couldn't find any detail on such API in samsung dev forum.

  2. I know ajax will not work for this purpose on browser or browser emulator (due to cross-domain restriction), but hoping it should work from real device or SDK emulators, right? If not what would be the best way to do this.

Thank you

Update: Reg #2 above: I found the XMLHttpRequest (ajax/jquery) will work in real device (in my case Samsung Smart TV Orsay). Tested myself in my smart tv. Even before testing, I was kind of confident about this after reading: http://blog.jaspermorgan.com/2013/04/matchmaking-jquery-and-samsung-smart-tv.html and https://github.com/BrightcoveOS/Samsung-Smart-TV-Sample-App (read "A note on local setup" section)

Upvotes: 1

Views: 811

Answers (1)

Egor Sazanovich
Egor Sazanovich

Reputation: 5089

  1. You're correct, AJAX is suitable for it and it's absolutely normal to use JS at web-app (and don't try to find any solution at OS API), so You needn't to worry about performance at data transferring level.
  2. If Your server disallow cross-domain requests, You'll stuck with the problem at real device for sure. I had same problem, but I was connected to developers of API that I used and they added required headers to server response (Allow-Origin) and only after that application started to work as planned. Shortly: if Your server doesn't allow CORS, You need to do something with it (for example create Your own server and send Your request to it instead of real one and on the server perform cURL or something like it)

Upvotes: 0

Related Questions