2

I want to get the users facebook profile picture and save it to a folder inside the project folder. By using this I can get the facebook pic; it displays the pic. Is there any possible way to download this picture and store inside a particular folder?

function getPhoto()
    {
      FB.api('/me/picture?type=normal', function(response) {

          var str="<br/><b>Pic</b> : <img src='"+response.data.url+"'/>";
          document.getElementById("status").innerHTML+=str;

    });
  • Can you also access the FB user server-side, as in do you have him authenticated there, you could or upload the `response.data.url` or just make a FB API call from the server – EaterOfCode Sep 01 '14 at 07:05
  • Why don't you use server side scripting language like `PHP` for this??? – Manwal Sep 01 '14 at 07:08
  • server side is in python. I didn't write anything there. I just tried out this http://hayageek.com/facebook-javascript-sdk/ and it's working. I only want to get the facebook profile pic not other details. – Michelle De Waas Gunawardena Sep 01 '14 at 07:08
  • You can simply send url of profile pic using `ajax` to python and save it as you want. @MichelleDeWaasGunawardena – Manwal Sep 01 '14 at 07:10
  • @Manwal I'm kind of new to this python and web development. So if I send the image URL to python can I save the image in a static folder? – Michelle De Waas Gunawardena Sep 01 '14 at 07:20
  • @MichelleDeWaasGunawardena: check this link: http://www.jensbits.com/2013/04/04/get-facebook-profile-picture-with-javascript-sdk/ – Manindra Singh Sep 01 '14 at 07:20
  • Sure @MichelleDeWaasGunawardena if you send image URL to python you can simply same image in static folder see this http://stackoverflow.com/questions/8286352/how-to-save-an-image-locally-using-python-whose-url-address-i-already-know – Manwal Sep 01 '14 at 07:22
  • @Manwal Thank you so much I'll try it out. But it's little hard to get the URL – Michelle De Waas Gunawardena Sep 01 '14 at 07:28
  • @MichelleDeWaasGunawardena its not hard you are already getting URL in `response.data.url`. – Manwal Sep 01 '14 at 07:29
  • Yes but if you copy paste that to the browser it will give an error message https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xpa1/v/t1.0-1/p100x100/10447748_10201164469474360_4694721062997975871_n.jpg?oh=e11d1a96e4c9945c0116226b390760e2&oe=546C237F&__gda__=1417633262_5e734ee5959c13221f86c2e572cece78 – Michelle De Waas Gunawardena Sep 01 '14 at 07:32

2 Answers2

0

javascript can't access files in the browser, you can do it on the server with nodejs. You can only store cookies in the browser.

Read/write to file using jQuery

Community
  • 1
  • 1
user3995789
  • 3,452
  • 1
  • 19
  • 35
0

You got facebook profile URL right.. Then send it to backend via Ajax. You problem will be solved.

teshvenk
  • 403
  • 3
  • 8