Uploading pics
How can I upload a picture taken from the camera component to Facebook??
Catch up wih the Appery.io community on our forum. Here you'll find information on the lastest questions and issues Appery.io developers are discussing.
https://forum.appery.io/
How can I upload a picture taken from the camera component to Facebook??
Facebook probably has API to upload pictures.
So...........once I get the API, do I apply it to the take pic button or the empty image box?
Hello! Using API you would need to create REST service to post pictures taken from camera to Facebook.
Hello,
this also may help
http://developers.facebook.com/docs/r...
http://developers.facebook.com/blog/p...
Hello,
I've been banging my head most of the day with this problem (how to post a photo taken with the app camera to facebook?)
I've been able to achieve it using a random picture url that i foun in the web, but when i try to use the base64 enconded result from the camera, it fails.
I've created a rest service to https://graph.facebook.com/me/photos and tried for "Request content type" JSON and Data (the latter using some JS based on this: http://stackoverflow.com/questions/16... )
The thing is, i can't make it work. Could you provide some complete example for uploading a base64 photo to facebook?
Thanks!
Hello!
I guess it might be caused by a known bug which is going to be fixed next week. Please check the workaround here https://getsatisfaction.com/apperyio/...
We are sorry for inconvenience.
Hello Maryna
I checked the workaround and the bug but i don't think im having the same issue (im only uploading one file, not many, and the code that i use is very similar to the one in that thread except for the looping of the multiple files).
I was getting a CORS related error, but then that was gone when i activated the appery.io proxy.
Now im getting a "400 (bad request)" error with the following message: "An active access token must be used to query information about the current user"
Obviously there is some trouble with the access token. How do i "place it" in the request of type Data ?
Here is what im doing, so please tell me where i'm wrong:
1- in the share button click event
code
var postData = getFbPhotoPostData();
try {
PublicarFacebookFoto.execute({
'body': {data: postData}
});
} catch (exception) {
console.log(exception.name + ' ' + exception.message);
}
/code
2- the getFbPhotoPostData function (im using a test image encoded as base 64 that i store in the variable "test64")
code
function getFbPhotoPostData()
{
var fd = new FormData();
var blobData = b64toBlob(test64, 'image/jpeg');
fd.append("access_token", Apperyio.storage.access_token.get());
fd.append("source", blobData);
fd.append("message",Apperyio.storage.mensajePostFb.get());
return fd;
}
/code
3- the PublicarFacebookFoto service settings:
URL: https://graph.facebook.com/me/photos
Method: POST
Response Data Type: JSON
Settings: None
Security context: None
Request content type: Data
Use appery proxy: checked
Thanks
Hi Juan,
As i see in this example: https://developers.facebook.com/blog/...
"access_token" should be send as "query string".
So please try to pass this parameter through "parameters" section in service "execute" function.
precode
//Make sure here is a correct access token.
console.log("Apperyio.storage.access_token = " + Apperyio.storage.access_token.get());
var postData = getFbPhotoPostData();
try {
PublicarFacebookFoto.execute({
'body': {data: postData, parameters: {"access_token": Apperyio.storage.access_token.get()}}
});
} catch (exception) {
console.log(exception.name + ' ' + exception.message);
}
/code/pre
Regards.
Hi Yurii
your code worked after i replaced:
pre
PublicarFacebookFoto.execute({
'body': {data: postData, parameters: {"access_token": Apperyio.storage.access_token.get()}}
});
/pre
with:
pre
PublicarFacebookFoto.execute(
{data: postData, parameters: {"access_token": Apperyio.storage.access_token.get()}}
);
/pre
But now there is a problem with the file upload itself, as it keeps giving me the error: "(#324) Requires upload file"
So, how i am supposed to deliver the file as multipart/form-data ?
Thanks!