0

enter image description here Access to scontent.xx.fbcdn.net was denied 403 error.

I made call on graph api as 'https://graph.facebook.com/me?fields=id,name,email,picture&access_token='+token

I got response as :

{  
    "id": "1000071187024512323243234",  
    "name": "XXXXXXXXXXXXX",
    "picture": {
        "data": {
        "is_silhouette": false,
        "url": "https://scontent.xx.fbcdn.net/v/t1.0-1/p50x50/sdsdfdfsfdsdfsfsdfsdfsdfsdfsdf.jpg?oh=d941c8cc91438c56f8449f596959eb2c&oe=58CCD44D"
        } 
    }
}

In the above response url is my profile picture. And you can see my code below:

Apex

global with sharing class facebookintegrationtest {   
    @RemoteAction public static List<String> getmyprofiledata(String accesstoken) {   
        String prof = facebookAPI.getownprofile(accesstoken);     
        String name = facebookAPI.getownname(prof);     
        String pic = facebookAPI.getownpicture(prof);   
        List<String> data = new List<String>();
        data.add(name);
        data.add(pic);
        return data;
    } 
}

Javascript

facebookintegrationtest.getmyprofiledata(facebookaccesstoken,function(result, event){
    if(event.status) 
        {                
          var name= result[0];
          var pic = result[1];
          document.getElementById('page').innerHTML = '<b>Welcome ' + name + 
            ' ! </b> Ex:- Your facebook page is :- 1) Sample facebook page. ';
          document.getElementById("profileimage").src=pic;
          getpostsjs();
        }
    }, 
    { escape: true }
);

Visualforce :

<div class="col-md-3">
    <div class="profile-thumb" style="margin-top:80px;">
          <img id="profileimage" src="" />
    </div>
</div>

Why image is not displaying? is there any blocking that server doesn't allow to set the image's source from client script?

  • Why returning a response, you should use wrapper. It gives more flexibility. Do you get the image in response after remote call? – Raul Nov 18 '16 at 11:47
  • Yes rahul i am getting image url in response. The error is shown in developer console :- Failed to load resource: the server responded with a status of 403 () Access to scontent.xx.fbcdn.net was denied. Its displaying broken link for image. – Innodel Salesforce Nov 18 '16 at 11:49
  • I have only one page to use. and i wanna to complete it only on that one page from: sending request for access token... to retrieving profile and comments and post on that same page. thats why i need to use json string. – Innodel Salesforce Nov 18 '16 at 11:52
  • Please add screenshot of dev console – Raul Nov 18 '16 at 12:05
  • Please check the question i had added the snapshot. – Innodel Salesforce Nov 18 '16 at 12:15
1

Facebook will provide link for profile pictures. It's their Secure content. It will not accept this type of javascript request. It will deny because it seems to facebook like you are stealing secret information using javascript.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.