html - Post photo to facebook page using javascript and graph api -


i using facebook javascript sdk post photo fan page.here's code

<form enctype="multipart/form-data" method="post"  action="https://graph.facebook.com/<page_id>/feed" target="ifram_name">       <input name="source" type="file" style="font-size:13px;" />       <input type="hidden" name="to" value="113342002047830"/>       <input type="hidden" name="access_token" value="user_accesstoken"/>       <input type="hidden" name="type" value="photo" /> </form> 

it says "missing message or attachment".

i have tried changing "action" "https://graph.facebook.com//feed" photo uploaded user's album.

can tell missing in code ?

you should use photos connection of user, page or album (not feed) , supply active access_token user/page.

<form action="https://graph.facebook.com/page_id/photos"       method="post" enctype="multipart/form-data">   <input name="source" type="file">   <input type="hidden" name="to" value="113342002047830"/>   <input type="hidden" name="access_token" value="user_accesstoken"/> </form> 

you can read more details in (year old) blog post how-to: use graph api upload photos user’s profile.

please note upload file application/code not notified on , user see response this:

{    "id": "1001207389476" } 

if isn't desired use server-side technology upload photos. option use js-sdk url parameter:

fb.api('/page_id/photos', 'post', {   url: 'http://example.com/image.png',   message: 'upload demo' }, function(response){   if (response && response.id)     console.log('photo uploaded', response.id); }); 

update:
please note should use page's access_token able post page's wall, if provide access_token user photo uploaded user's application album regardless of to parameter. see authenticating page on details how access_token page.


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -