facebook - Uploading image to FB staging server using jssdk returns error -


i'm creating fb app upload , post images user's wall, , i'm stuck @ point. upload images on fb staging server, because server small. when try post image code

fb.api('/me/staging_resources?access_token='+access_token, 'post', {file: file_uri}, function(response) {         if (!response) {        alert('error occurred.');      } else if (response.error) {        console.log('error: ' + response.error.message);      } else {        console.log('file uri ' + response.uri );        file_uri = response.uri;      }     }); 

where file_uri variable contain https address image, receive error "(#100) invalid file. expected file of 1 of following types: image/jpg, image/jpeg, image/gif, image/png". tested graph api explorer, same error. tried everything, put url file generate image, put direct url image, http, https, image other site... same. have me, maybe missing something?

thanks in advance, nikola

edit - solution

thanks again jason, succeeded image, if ran problem, solution make separate curl file calls https://graph.facebook.com/me/staging_resources url of image , access token, , in js file make simple call

$.get('/curl.php?url='+image_url+'&access_token='+access_token,function(response){         console.log(response); }); 

according documentation, file parameter needs file data (as in enctype='multipart/form-data' http post). example show posting via curl:

curl -x post \   https://graph.facebook.com/me/staging_resources \   -f "file=@images/prawn-curry-1.jpg" \   -f "access_token=$user_access_token" 

it cannot take uri resolves file (you have preform fetch)


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -