Facebook PHP SDK - Obtaining an access token automatically - php

I am trying to connect to the Facebook Graph API using the PHP SDK and view recent posts of a business account. BTW: I know there is a widget available for this task, but due to speed constraints, I would rather access the API and cache the response myself.
So I used my personal account to sign up at developers.facebook.com, created an app and obtained an AppId and AppSecret. My question relates to obtaining an access token for use with the graph API using the PHP SDK.
The examples on the getting started page shows how to obtain an access token by manually clicking a link and receiving a callback to my website. I am not creating a public app as such, I don’t want a manual login because my script will be run periodically by the server.
In any case if I click the Log in with Facebook! link, I get the following message which I don't understand:
The Twitter API provides automatic authentication but I cannot understand how to impliment this using Facebook. Can anyone point me in the right direction?

Related

GMB PHP API 2020 Issues

I am working on the GMB API, facing some issues. I have implemented Google Oauth at frond-end and saving user listing in my DB. Now I want to run cron job in which I want to get those user`s listing insights. So issues are here
1: I can't find GMB API samples or doc regarding GMB stuff(I have read all google-api-php-client doc).
Here are GMB samples but it doest have PHP samples.
https://github.com/google/google-my-business-samples
2: Second thing is that I don't want to open consent(Google Account Selector Popup) to get the user's permission because its a backend process. So what type of process should I follow a) Oauth OR b)Service Account.
If I use the Oauth process then I have to save access_token in the database when the user first time gives permission at the front end of the website and uses that token as refresh token to get the new access token in PHP and call GMB APIs.
But the issue is that we have already registered 500+ users, so how I will get their access token because they are already done with google permissions.
I didn`t try yet with a service account.
I am using Laravel 5.7 version.

Wordpress Plugin Authenticate With Facebook WIth No AppID

I am working on my first wordpress plugin and posting to facebook. I have been looking for the last few days for ways to authenticate with facebook. I have found numerous sites that use the method of having the user create an App and then input the AppID and App Secret. However, I have used plugins before that use Oauth (I think) as it opens a pop up and the user basically logs into facebook and then says this app (your wordpress site) wants to control things.
Does anyone know of any resources for authenticating with Facebook without the user having to go through the trouble of creating apps?
Examples I have found but they require APPid and App Secrets.
http://www.sanwebe.com/2012/02/post-to-facebook-page-wall-using-php-graph http://www.pontikis.net/blog/auto_post_on_facebook_with_php
My anticipation is that they set up a website and create a single app for that. Then the plugin calls that website, gets the access token, and sends it back?
The wordpress documentation is quite confusing to me.
Creating an app takes about 5min, so I don't really see an obstacle here.
IMHO there's no other way than either
Using an app with FB Login to obtain the permission to post on a user's/page's behalf, or,
Getting an access token via the Graph Explorer and use this for your plugin
Please be aware that user access tokens expire after max. 60 days.

Getting all posts related data for a facebook page

For my web application - I need to fetch all the data for a particular facebook page. What kind of permissions do I need. Do I really need to create a canvas app for it?
I dont intend to do anything on FB - but use some of the data available to arrive at some conclusions in my web based application which will be hosted on a server outside of FB.
Facebook's API documents should provide everything you need:
https://developers.facebook.com/docs/graph-api/reference/v2.1/page
According to the permissions section, you'll need either an App token or a User token. Since you're talking server-to-server (I'm assuming this is server-to-server on account of the PHP tag), you're going to want to use an App token:
https://developers.facebook.com/docs/facebook-login/access-tokens#apptokens
You should be able to create a Facebook App from within your Facebook account, which will provide you with an App ID and App Secret. You can use those to make calls directly to the API.

Facebook Application Authentication Using the PHP SDK

I'm currently trying to create a canvas application for Facebook and I'm trying to get it so that the user has to verify they want to authorise the application before it runs.
I'm trying to do this with the PHP SDK but to no avail so far.
Is there a way to automatically redirect to check if a user has authenticated the app?
Thanks,
Scott
If you request for a application authentication to facebook, and the app is already authorized by the user, the authentication window does not show again. It straight way returns a token.
You can check this tutorial http://thinkdiff.net/facebook/graph-api-iframe-base-facebook-application-development-php-sdk-3-0/ its a nice one to get started .

oAuth authentication on every site visit

I'm trying to implement a transient oAuth authentication for a web app I'm creating. Essentially, the user needs to login with the Service each time they visit my web app. Primarily it's to enable using the web app without me having to store any of the user's authentication data. I'm trying to use the Tumblr API.
My platform of choice is PHP. However I've never really worked with oAuth before and and am still learning. The following scenario illustrates what I'm trying to achieve:
The scenario assumes that:
The user has already authorized my application in their Tumblr account.
Using my Tumblr Consumer Key, Tumblr Consumer Secret, I call to get request_token, which I later display to the user via a link.
Now on clicking the link above, I expect Tumblr to NOT to ask user to allow the app again (authorize in their account) and simply redirect user back and returning some info that will allow me to distinguish the user. There is no $_SESSION as user is trying login to the website using Tumblr
Is this even possible? If yes, can you help me figure out how to get this done?
Ps. I'm a complete oAuth Noob so please be gentle :)
If you are trying to use Tumblr in a way similar to Facebook Connect, Tumblr does not offer this feature at the moment. ie: you can not use Tumblr to log into your site.
Tumblr's OAuth implementation will allow you to have the user allow access for your app to the users account indefinitely. Which means that your app will always be able to access the users account, whether they are logged into your site or not. They will still have to log into your site each time they want to access your app.
Here is a solid guide to OAuth. Tumblr uses OAuth 1.0 :
http://hueniverse.com/oauth/

Categories