【发布时间】:2014-12-09 21:44:08
【问题描述】:
我正在使用 Parse 并为我的应用程序编写自定义后端。我需要做的一件事是获取 Facebook 个人资料图片并将其存储为图像文件。但是我收到了 HTTP 错误代码 302。我理解错误 302 是由于重定向引起的。我正在寻找这种情况的解决方案。不,我无法从客户端获取图片并保存图像文件。我必须使用 Parse Cloud 代码来获取 Facebook 图片并保存。
这是我正在使用的代码
Parse.Cloud.define("fetchFacebookProfilePicture", function(request, response) {
Parse.Cloud.useMasterKey();
var Image = require("parse-image");
var user = Parse.User.current();
if (user == null) {
response.error("user is NULL");
}
var profilePictureURL = "https://graph.facebook.com/"+user.get("facebookId") +"/picture?type=large&return_ssl_resources=1";
return Parse.Cloud.httpRequest({
url: profilePictureURL,
method: "GET"
}).then(function(response){
//var image = new Image();
response.success("All set");
},function(error){
response.error(error);
});
});
这会返回以下错误
{"uuid":"229e2f43-7533-0149-3bbc-c69970e04d7e","status":302,"headers":{"Access-Control-Allow-Origin":"*","Cache-Control" :"private, no-cache, no-store, must-revalidate","Connection":"keep-alive","Content-Length":"0","Content-Type":"image/jpeg","日期":"格林威治标准时间 2014 年 12 月 9 日星期二 19:38:40","到期":"格林威治标准时间 2000 年 1 月 1 日星期六 00:00:00","Facebook-API-版本":"v1.0","位置":"https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xpa1/v/t1.0-1/s200x200/1920432_10153903894020578_1014472787_n.jpg?oh=40dc964b1d8dd29f618387944050fff4&oe=55059D07&gda=1427550917_a067d3a93e9a1dd1a92a258258deb415","Pragma":"no-cache","X-FB-Debug":"XydW5s6z3jTiOzFBmToC63AquyYBCc5Ye5W6vX88j7NFwsubSqqDxiQQnta7Gp0JU/4VYKFN6wY4qufMN+vHPA==","X-FB-Rev",}}" "text":"","buffer":{"length":0,"parent":{"length":0},"offset":0},"cookies":{}}
【问题讨论】:
-
您是否曾经为此找到解决方案/解决方法?
-
不。我不是。如果有解决方案,那就太好了。