How to base64 encode an image from the facebook api

后端 未结 4 1628
北恋
北恋 2021-01-23 06:21

I am attempting to convert an image url provided by the facebook api into base64 format with cURL.

the api provides a url as such:

https://fbcdn-sphotos-         


        
4条回答
  •  天命终不由人
    2021-01-23 07:16

    I had similar problem. My solution:

    $url = urldecode($url);
    return base64_encode(file_get_contents($url));
    

    Where the URL is to Graph API:

    https://graph.facebook.com/$user_id/picture?width=160
    

    (You probably want to also check, if file_get_contents returns something)

提交回复
热议问题