Naren
Naren

Reputation: 1702

How to fetch image in Roku BrightScript?

The below Curl returns an image. I am struggling to find Roku equivalent code to fetch an image and display it in poster node.

curl -X GET \
  https://xiorchestrate-xos-svc.prod.ocean.com:8443/xos/users/ocean-cf0183fb-9e93-4964-859b-XXXXXX/photos/profile \
  -H 'Accept: */*' \
  -H 'Authorization: Bearer XXXXX-9024-44b4-8552-d7d799ec00c8' \
  -H 'cache-control: no-cache'

Can someone help me?

Upvotes: 2

Views: 592

Answers (2)

Lokesh Singh Sodha
Lokesh Singh Sodha

Reputation: 1

You need to make poster node for implementing the image in roku. Create a poster node with <poster /> tag with id and other things like width and height and tranlation, etc,. in xml. After creating the poster node you need to find the node using id with Findnode method in the brs file, like m.poster_id = m.top.findnode("poster_id") here m.poster_id is the glbal variable we initialize for using it for performing another operations. Now, time to set the image uri into the poster node: m.poster_id.uri = "images/image1.png"

Upvotes: 0

Alejandro Cotilla
Alejandro Cotilla

Reputation: 2621

Poster nodes implement the ifHttpAgent interface therefor you should be able to use the SetHeaders(nameValueMap as Object) function before setting the uri to the poster.

m.poster = m.top.createChild("Poster")
m.poster.SetHeaders({"Authorization": "Bearer XXXXX-9024-44b4-8552-d7d799ec00c8", ...})
m.poster.uri = "https://xiorchestrate-xos-svc.prod.ocean.com:8443/xos/users/ocean-cf0183fb-9e93-4964-859b-XXXXXX/photos/profile"

Upvotes: 3

Related Questions