Google drive file access - php

I am writing a PHP script which is supposed to pull some data from a google drive spreadsheet. Now, important thing here is that we're talking about one specific spreadsheet, which is on one exact google account. This data needs to be displayed on a site. That means that when a user visits this site, he/she should not need to login/authenticate or anything like this, because the spreadsheet being accessed is stored on one specific google drive account.
How do I pull this one? All I see online are examples where users login to their own account, viewing their own files which I don't need.
Thanks!

All Drive access requires authentication. The only way I can think around it is to publish the spreadsheet using File/Publish to the web. You app can access the data using the published URL without authentication.

Related

Google Spreadsheet User login

Okay, So I have a client that wants their wordpress site to only require user to use their email to login. They instead want the site read through a google spreadsheet of all the users. Then if the users email is found in the spreadsheet it allows the user to login.
Before people start screaming, I know its extremely bad from a security stand point, we've told them this. They don't care.
So my question is, has anyone one done this or something similar in the past. How did you do it.
And how would say is the best way to go about doing this. So far I have thought of a few ways to do it.
Secretly embed the doc on a hidden web page then access it.
Some how just access it using APIs
Maybe using google forms as the email entry, and some how use that to search the google docs.
Any ideas or helps, is appreciated greatly. Thank you.
Logging in via an email address is easy, there are already plugins to do it. https://wordpress.org/plugins/wp-email-login/
There is also a plugin for external authentication. Don't know if it does it from a spreadsheet, though you may have a way to sync the spreadsheet to an external DB (via an API perhaps):
https://wordpress.org/plugins/external-db-auth-reloaded/
Would you need the logged in user to have any user-specific account info? Could you get by with allowing each logged in user to essentially be using the same single account in WordPress?
I could see a solution where you hook into wp_authenticate() https://codex.wordpress.org/Plugin_API/Action_Reference/wp_authenticate
And in your hook function call, run out to Google Spreadsheet via their API and see if that email address is found in the list. If so, log them into WP using a preset, single account that's meant to be used for all such users.
Here's some basic info for reading from a Google Sheet via their API:
https://developers.google.com/sheets/samples/reading

Access box.com files by share link

I want to be able to serve up box.com documents to users on my password protected web site. I want to to develop a little php program that will accept a box.com share link, and using the box.com api and a OAUTH 2.0 token, retrieve the file from box.com, and then send it to my users.
Is this the best way to do this? There really isn't the need for an OAuth flow, as I am accessing my own files on box.com, I just want to make sure that my users are logged in.
I also don't want to simply share my box.com files to the whole internet.
My question: Is there a way to access a document on box.com via the api using the box share link. What I mean is that the share link looks like: https:/...domain.box.com/xxxxxxxxxx
Can I someone use the xxxxxxxxx as an ID to get/files/fileid/content api call?
Is there a way to search for a document by its share link?
I want to use the share link, because non-technical people will be generating contact, and I'm concerned that they will have trouble getting the FILEID of the box.com files.
The Box documentation answers your question:
Create a shared link for a file:
https://developers.box.com/docs/#files-create-a-shared-link-for-a-file
Anyway, I'm working on a Box Php Sdk, I hope it helps you: https://github.com/adammbalogh/box-php-sdk

user's last login date and time facebook graph explorer

I have search a lot on this site and google to get the last login date and time of a particular facebook user from user id using the graph explorer. However, could not find a relevant article.
I have 20+ employees working in my office and I do not want them to access facebook during shift timings. I have their user ids with me. Is it possible to check when did they last login/logout or performed any activity on facebook using their FB UIDs using a php/mysql or any other way or just by using the graph explorer?
I read some articles that had fql options but i could not try those as fql is depreciated. Any help here would be appreciated.
Thanks
Did you meant to use a Graph or Graphic ?
Using a table to log-in when your users accessed Facebook will be simpler.
You'll have to apply a filter to remove results outside the shift timings.
Once you are done with it, creating a bar graphic will be an easy solution.
If you want to use the Graph API, you need to make sure that your employees log-on onto your application and give their consent.
You should check : https://developers.facebook.com/policy before trying anything.
Only use our SDKs to develop and distribute apps for use with the
Facebook Platform. You may also distribute any code libraries or
sample source code included in the SDKs for inclusion in such apps.
Use simple network functions like logs to collect data.
Enabling a Firewall is better than making Facebook accessible in those shift hours.
If you meant Graph API, it's a social graph explorer. It's meant to show all the relations between the users. I am not sure how far it deviates from a graph, neither if it has some visualization capabilities.
Using the Graph API to monitor your workers might be a grave legal infringement. There are many laws protecting privacy at work. The Graph API can give all kind of information. I would not suggest to use any kind of solution that gives access to some sensitive data...
Logging all the Connections going to FB would be the only choice.

Uploading videos to a specific PREDETERMINED account with YouTube API v3

I have a website on which clients will be uploading videos. The thing is - I want those videos to be uploaded to OUR channel, not users' channels. I don't see how I could make it work using YouTube API v3.
Every time a person wants to upload something using the access token I provided he has to input his own credentials. He can't simply upload anything directly to OUR channel.
Is there a way to work that around?
Short answer is: You should not ask your users to upload into your account.
But please read further:
https://stackoverflow.com/a/12626209/1973552
https://stackoverflow.com/a/15258781/1973552
Api V2 have option you've mentioned. Did you try it?
Basically you want to let Users upload Videos in your website, but upload them directly to youtube, without Google AUTH?
Yes you can. Make sure you set the setAccessType to offline.
$client->setAccessType("offline");
This will make it so you get a refresh Token with the users account authentication the first time. A refresh token allows you to reauthenticate without the user being present. (aka, offline). Create your script from the sample API v3 scripts, authorize your main account (the one you want to be predetermined) and display the response. Something like the following will show you your response:
print_r($client->getAccessToken());
You will see your refresh Token in the json response. Save that (either to a database, or hard code it into the script). Now that you have a refresh token, whenever you want to upload to youtube, just call
$client->refreshToken($THE_REFRESH_TOKEN_YOU_SAVED);
$thetoken = $client->getAccessToken();
$client->setAccessToken($thetoken);
After this, your previously authenticated account will now be currently logged into your script.
FYI, these are php examples, you might need to adjust accordingly.

Take the likes from users of my app and file them into csv

I need to be able to consolidate all the likes from users that use my Facebook app into an Excel or .csv file. I can have the user authenticate within my Facebook app, but is there a way to see the likes for all users of an app using Open Graph or some other Facebook tool? I'm certain that someone else must have had this problem, and I'm hoping that one of you can help me out!
I've been trying to run FQL queries to bring up likes, but don't have any experience with PHP so it has been miserable so far. Any ideas?
There's no way to retrieve a list of users of your app - you'll need to manually build that as users authorise the app see this question for more information
Assuming you have permission to access a user's likes connection - access /USER_ID/likes and parse the response, saving it to a file in accordance with whatever language you're using's syntax (google is your friend here)
Note that your use of the data is subject to Facebook's policies and user's consent in accordance with your privacy policy and sharing it with third parties may be illegal (i am not a lawyer, this is not official advice, etc etc)
Here is the problem with that the application type does not have a like connection. Application Object GraphAPI This is inconvenient when you are looking to gather data on the users that like it.
OR were you talking about the likes endpoint of the user object? That you can gather but I dont think it is what you are looking for. It is shown here Graph Explorer Example - user's likes

Categories