Page 1 of 3

Uploading pics

Posted: Wed Feb 13, 2013 4:06 pm
by Chris Ross

How can I upload a picture taken from the camera component to Facebook??


Uploading pics

Posted: Wed Feb 13, 2013 4:27 pm
by maxkatz

Facebook probably has API to upload pictures.


Uploading pics

Posted: Wed Feb 13, 2013 5:35 pm
by Chris Ross

So...........once I get the API, do I apply it to the take pic button or the empty image box?


Uploading pics

Posted: Thu Feb 14, 2013 6:58 am
by Maryna Brodina

Hello! Using API you would need to create REST service to post pictures taken from camera to Facebook.


Uploading pics

Posted: Thu Feb 14, 2013 3:51 pm
by Kateryna Grynko

Uploading pics

Posted: Sat Nov 22, 2014 12:26 am
by Juan Story

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!


Uploading pics

Posted: Sun Nov 23, 2014 8:32 am
by Maryna Brodina

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.


Uploading pics

Posted: Tue Nov 25, 2014 5:48 pm
by Juan Story

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


Uploading pics

Posted: Tue Nov 25, 2014 11:03 pm
by Yurii Orishchuk

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.


Uploading pics

Posted: Wed Nov 26, 2014 6:02 pm
by Juan Story

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!