You need to sign in to do that
Don't have an account?
Ravikant kedia
I want to upload photo on facebook ?
I am doing integration salesforce with facebook . After authentication i want to upload photo on facebook i made one visualforce page in which i select photo and pass to controller as a blob.
My code is------
public void uploadPhoto()
{
String bodyEncoded = EncodingUtil.base64Encode(file);
System.debug('------------------------------------------'+bodyEncoded);
// bodyEncoded='%7B'+bodyEncoded+'%7D';
String boundary = '----WebKitFormBoundaryE19zNvXGzXaLvS5C';
// String message=''
String body=boundary + '\r\n'+
'Content-Disposition : form-data; name="source"; filename="'+filename+'"\r\n'+
'Content-Type : '+filetype+'\r\n'+
bodyEncoded +'\r\n' +
boundary;
System.debug('----------------------------------body is-------------\n'+body);
HttpRequest req=new HttpRequest();
req.setMethod('POST');
req.setbody(body);
req.setHeader('Content-Type', 'multipart/form-data; boundary="'+boundary+'"');
req.setHeader('Content-length', String.valueOf(body.length()));
// req.setHeader('Content-Encoding','base64');
req.setEndpoint('https://graph.facebook.com/v2.0/me/photos?access_token='+accesstoken);
HttpResponse res = null;
http h= new Http();
res= h.send(req);
system.debug( '------------upload photo----------------------'+res.getbody());
}
I am gettung error each time ({"error":{"message":"(#324) Requires upload file","type":"OAuthException","code":324}})
please tell me sir what i have to do for uploading photo on facebook.
thanks in advance
My code is------
public void uploadPhoto()
{
String bodyEncoded = EncodingUtil.base64Encode(file);
System.debug('------------------------------------------'+bodyEncoded);
// bodyEncoded='%7B'+bodyEncoded+'%7D';
String boundary = '----WebKitFormBoundaryE19zNvXGzXaLvS5C';
// String message=''
String body=boundary + '\r\n'+
'Content-Disposition : form-data; name="source"; filename="'+filename+'"\r\n'+
'Content-Type : '+filetype+'\r\n'+
bodyEncoded +'\r\n' +
boundary;
System.debug('----------------------------------body is-------------\n'+body);
HttpRequest req=new HttpRequest();
req.setMethod('POST');
req.setbody(body);
req.setHeader('Content-Type', 'multipart/form-data; boundary="'+boundary+'"');
req.setHeader('Content-length', String.valueOf(body.length()));
// req.setHeader('Content-Encoding','base64');
req.setEndpoint('https://graph.facebook.com/v2.0/me/photos?access_token='+accesstoken);
HttpResponse res = null;
http h= new Http();
res= h.send(req);
system.debug( '------------upload photo----------------------'+res.getbody());
}
I am gettung error each time ({"error":{"message":"(#324) Requires upload file","type":"OAuthException","code":324}})
please tell me sir what i have to do for uploading photo on facebook.
thanks in advance
http://stackoverflow.com/questions/15428959/errormessage324-requires-upload-file-typeoauthexception-code
http://stackoverflow.com/questions/8671937/posting-photo-to-fb-results-in-requires-upload-file-error
https://developers.facebook.com/docs/graph-api/reference/v2.0/user#photos