Is it possible to read FB page ratings server-side? - ruby-on-rails

I need to create ratings grabber from my Facebook fanpage. It can by PHP, Python or Ruby code fired once a day by cron.
I've created an FB_APP so I get APP_ID, APP_SECRET and CLIENT_TOKEN.
When I use Graph API Explorer, there is a access_token which I can use to temporary call to API. Using generated USER_ACCES_TOKEN I can get PAGE_ACCESS_TOKEN by call
GET https://graph.facebook.com/v9.0/me/accounts
then grab page and token
To get ratings I use
GET https://graph.facebook.com/v9.0/{page_id}/ratings?fields=review_text,reviewer&access_token=xxxx
Parameter access_token is a PAGE_ACCESS_TOKEN.
Is it possible to get USER_ACCES_TOKEN or PAGE_ACCESS_TOKEN server-side only without show user login dialog? My script should download ratings without any user attention.
I tried to use OAuth APP_ACCESS_TOKEN, but it is not permitted to access pages.

Related

Send a POST request from the Google account that’s signed in with Google Apps Script

I try to find a way to submit a response to a Google Form that I do not have edit access to with Google Apps Script. Both of the FormApp.openById(id) and FormApp.openByUrl(url) methods need the user who is signed in to have edit access to the form, so I can't use those. The request has to come from my account because the Google Form keeps track of which account each response is from.
I know that it is possible to pre-fill a Google Form by adding values for specific fields on the end of the link. It is also possible to respond to a Google Form like that with just a POST request. However, I have only been able to make this work for Google Forms that don't need the user to be signed in.
To solve this problem, it would be great if there was a way to send a POST request from the Google account that is signed in.
Currently, it is not possible to submit a Google Form without edit access. As you mentioned you can only make this work for Google Forms that don't need the user to be signed in (either by server-side POST or URL redirection on client-side).
Alternatively, client-side redirection will allow you to submit the Google form for the signed-in user, but it will show the google form's confirmation message.

Read outlook mails through MS 365 graph client without login form

I have to read Outlook emails from an inbox in a Windows Console Application. I am trying to use MS Graph Client for the same. Problem is I don't want to login to generate access token. How should I go about generating access token without a login form ? I will appreciate any help.
I have tried the solution given in this article, but couldn't get it working as I didn't know redirectUrl and couldn't resolve some references for the given code.
Single user -> Use device code flow
If you want to access the mailbox of a single user: you can use the Device code flow documentation.
This flow allows you to display a code to the user, they go to the device login page and authorize your application. You also get a refresh token so this access can be used for a log time.
Any user in organization -> Use client credentials
If you want to access any mailbox of the entire organisation you can check out this answer and replace the required permission by Read mail in all mailboxes.

Are Facebook Page Access Tokens temporary?

I am trying to determine if page access tokens used with the messenger api are permanent. Seeing this code in one of their examples, which indicates to me that they are using the token as a constant value :
access_token: PAGE_ACCESS_TOKEN
I get the Page Access Token shown on my facebook app dashboard in this way:
I log into facebook, go to developer.facebook.com, select my messenger app, then on the dashboard go to Products > Messenger > Settings and can select my page and then get a token.
Can I put that value in a properties file and then use it indefinitely with my application when getting/sending messages to and from the page?
I am getting a bit confused regarding the documentation around other tokens, like user tokens and login tokens vs. page tokens.
Editing to add that I am using the page access token in order to make a POST request to this url : https://graph.facebook.com/v2.6/me/messages in order to reply to a message sent to my page by a user.
I believe I have solved this and wanted to post in case anyone else had the same confusion.
I assumed I needed to make a GET request to a facebook url in my code to get a new token before each Request to GET or POST to the messenger API. Using the information in the links above, I learned how to get an extended token here:
https://developers.facebook.com/tools/explorer/<my app id here>?method=GET&path=me%2Faccounts&version=v2.10
I then can use that ID indefinitely as it is supposed to not expire. I am going to assume it is OK to put this id into my properties file, if anyone has opinions on a better place to store this token value I would be interested.
Extended Page Tokens are valid forever.
You need to use a User Token, extend the User Token and then get an Extended Page Token with the Extended User Token.
More information:
https://developers.facebook.com/docs/facebook-login/access-tokens/
http://www.devils-heaven.com/facebook-access-tokens/

Get Twitter id with Screen Name

Hi I'm trying to get Twitter ID by Screen name..
Screen name is: KTutorials
Here is my link to get Twitter Id
https://api.twitter.com/1.1/followers/ids.json?cursor=-1&screen_name=ktutorials&count=5000
But I'm getting this error.
{"errors":[{"code":215,"message":"Bad Authentication data."}]}
Here is my Twitter link https://twitter.com/ktutorials
Any Help?
I can see that you are using Twitter API to GET followers/ids method. GET request for this method require OAuth Signature. This means that you should have Twitter App created and if not, you should have create one here.
Subsequently, you should visit GET followers/ids documentation page, and get OAuth Signature using the "OAuth Signature Generator" located at bottom of page.
Bad Authentication data tells that you it can't do the operation due to the bad authentication.
From API V1.1, all requests should be authenticated first. So, create
an app in Twitter console and put the important keys like Access keys
and Consumer keys.
If you feel you are authenticated user, then re-generate your token and give another try!

fb_graph / general facebook API question

How is the server-side flow supposed to be for Facebook Apps? What I mean is, on every page load, do I have to get an access token?
Currently, in my application_controller, I have a before filter that basically
redirect_to #fb_auth.client.web_server.authorize_url (authorizes the app)
#fb_auth.client.web_server.get_access_token (gets the access token)
This seems really slow to have to get another access_token from Facebook on every page load. How is this normally done? The problem that I'm having is that to access the /me object you have to get an access token, which requires me to get the access token on every page load.
You shouldn't need to get a new access token on every page load. The access token should be good for many page loads as it takes over an hour to expire (expiration info is available when you get the token).
Also you don't have to redirect every time. On POSTs to your app (such as when the user clicks over to your app) a signed_request is included with the post data. If the user has not authorized your app, that's the time to redirect to the fb_auth. If the user has previously authorized your app, an access_token should be in the signed_request.
More info here:
http://developers.facebook.com/docs/samples/canvas/
there is a sample skeleton application available # https://github.com/michaelbaldry/fb_graph_canvas
access_token is gained when a person first visits the canvas url on apps.facebook.com/appname/ once this has happened the access_token is stored in a table and used until the next time the user comes straight to the canvas url.

Resources