+ Start a Discussion
testtaroutesttarou 

I want to use a profile image with REST API and proxy.php.

I want to use a profile image with REST API and proxy.php.

However,a JSON returened by REST API doesn't have a profile image url on API's domain.
It has the url on "xxx.salesforce.com" domain.
Therefore,to use REST API and the picture ,it needs to login twice(rest api and force.com)
I don't want to force my user to login twice.
Please tell me solution for this problem.

 

LoganLogan

Chatter profile images accept Oauth access tokens in the header just like other API requests.  You should proxy the image requests through your server in order to add the token to the header.  For instance in my sample app the code looks like:

 

class Chatter::UsersController < ApplicationController
  before_filter :require_login
  
  
  # proxy request for user profile photos (any photo really) because
  # these require an authenticated request
  def photo
    url = params[:url]
    image = @client.http_get(url).body
    send_data image,  :disposition => 'inline'
  end
  
  
end

 

 

testtaroutesttarou

Thank you for your reply.

 

I understand what you mean.

The code you write is ruby(and rails).

I have to add proxy code for image to proxy.php.