Search code examples
facebookfacebook-graph-apifacebook-javascript-sdk

Facebook Graph API - Post a photo in an album with page admin access token


CONTEXT

So I have this Facebook page where I sell baby products. Every now and then we organize a photo contest as it has been proven an effective way to engage with the customers/community. Previously, we used to get photos from the customers and manually upload each and every one of them in an album.

Problem Automate the process of

  1. Getting an image from the customer
  2. Uploading them into the album
  3. Provide the customer with the URL

with: The customer being able to upload the image on a UI(form as attached below) from the website which should upload the image in the Facebook album and return the URL back to them via Graph API. [Not sure if its a good idea, please feel free to advise :) ]

This is what I've built: enter image description here

QUESTION

What should be the flow of getting the permanent access token where the customer won't have to log in. Maybe get a PageAccessToken with reading and write permission and process the automation from there? What would your flow be if this case scenario? I want to avoid the customer having to log in as we don't need their data at all. All I need is them to post the photo in the album of my page. Being new to the FB Graph API, I would really appreciate a step by step approach to solve the problem.

I am using VUE JS and Facebook JS SDK. Backend PHP.. Cheers!


Solution

  • I have reached the conclusion after a few research and suggestions provided by @CBroe that designing the app like the way I initially imagined is not very practical and here is what I have decided to do:

    1. The customers will be able to send the required information by filling the form
    2. The information will be saved in a database including the image
    3. The first thing will be to generate a user access token
    4. Generate Long-lived user access token
    5. Generate Long-lived page access token
    6. I have decided, instead of pushing the photo directly to Facebook, it'll be first approved by the admin
    7. If everything alright the admin will post it to the Facebook album with a push of a button

    So, my solution is to automate posting to the Facebook where the admin has to push a approve button instead of the customer being able to directly post the photo on Facebook. I will try to post a link to git after it's done.