I saw a post two days ago :
google api calendar php
And it looks like the code I need. I am only an amateur php programmer. I had been using Zend Framework to connect my website to a Google calendar to make changes on the calendar from my site,but now deprecated as it used V2 of Google API.
So now I am trying to use the PHP client library and have gone to the Google Developer console and created what I think is an 'App' (service account) to use the php client library. In the code in the above post there is a line:
$client->setApplicationName("My app");
I am not sure what that refers to? I have a 'project name' when creating it in the console but I am really not sure if this is the 'App name'. Or worse maybe i am not creating an app at all and have made a mistake. I have all the other parameters like client ID, key file and service account.
P.S. I saw one post where you had to add client ID to the ../src/Google/config.php file - is that needed as well?
thx
I found all the advice on setting up a service account and also the code for adding an event at daimto.com
App name can just be the project name form your Google console too BTW.
Related
I am new to AZURE O365 portal, I have created some users in azure portal.
How can I create API in Azure portal to get the user details which I have already created in the portal and are they users enabled or disabled using PHP.
I tried: I have created application and I created secret Id in the portal, then what I have to do, to generate API for user list using php.
please help on it.
Thanks
Sandeep
Not sure if I undestand you correctly: you created some users on the azure portal and you want to get these users using PHP?
Azure has many APIs, they also have an API for getting these users, here is the specification and example code (not in php, but I think still easy to understand):
https://learn.microsoft.com/en-us/graph/api/user-list?view=graph-rest-1.0&tabs=http
Basically you can access that data using graphql client. There are many graphql libraries for php. But as I skimmed through the docs, you don't really need a library, just a way to create http requests, I recommend Guzzle.
Before you create that php code, I recommend to simply play with the API by using postman or other api client. If it works there, you can start to create the php code.
The code is basically a http POST request (or whatever is specified in the documentation). The request should contain your API tokens in the header, thats all. Data will be provided usually as JSON. Here are some examples how to use guzzle in php for graph.
After hours of work I am stuck with using google calendar php api, I need the basic functionality, reading and adding events (updating and removing later), any advice? I need the solution that works with the recent version of the api and is relatively simple.
Everything you need is well documented on Google Developers website. You will need composer to be running in your project and a Google Account.
On Google Developers page listed above, click Enable the Google Calendar API, select existing project or create a new one and click next. You will get your Client ID and unique Client Secret. You can manage this credentials in API Dashboard. Download these credentials.json and put them in your workdir.
Then you can setup composer for Google Client Library
composer require google/apiclient:^2.0
Now you can set up the sample. Create a file named quickstart.php and put there this code. You can run the sample using php quickstart.php.
Would you like to share your code with us, so we will be able to support you with more relevant answers?
I want to create a new Id Client Oauth 2.0 for Google Drive API, then generate the object JSON (oauth credentials), download it and place it in a specific folder, without the use of the console developers google. Is there a script (in php or javascript) that produce this with the email and password of a google account?
I want to create this "standalone script" because I dont want that the client must go before on the google console (although it will be for one-time).
thanks,
Matteo
It is not possible to programmatically create a project on Google developer console. The only way to create a new project is to do it though the website manually.
You are not going to find a script or anything to allow you to do this. The only think that remotely resembles this is the Google Cloud Resource Manager API but its not going to let you create credentials.
Following this Google Tutorial : https://developers.google.com/analytics/devguides/reporting/core/v3/quickstart/service-php
And using this PHP library :
https://github.com/wanze/Google-Analytics-API-PHP
I have a little problem. I just don't find the email to use as described in the tutorial. I think the API interface has changed, and the tutorial is old.
I have created my project, activate Analytics API, and create a "Service account". It generates an email, but not in projectId-uniqueId#developer.gserviceaccount.com format.
I tried with the new email created (like name#name-1162.iam.gserviceaccount.com) but I catch this error :
invalid_grant
Is something changed ? What I am doing wrong ?
On the page you linked there is a basic setup:
https://github.com/wanze/Google-Analytics-API-PHP
First step is,
Create a Project in the Google APIs Console:
https://code.google.com/apis/console/
And that differs completely from the other guide you have.
At best follow what it says on the github page.
I want to start developing a tool that runs daily via cron for getting daily analytical data from one channel, or video, etc.. through the "Youtube Analytics API". And not what is the best way to approach it.
I have read the documentation of Google and and I have several questions:
I created the project in the console (https://code.google.com/apis/console/) but I doubt what kind of application I have to choose when I create a Client ID (Web Application, Service Account or Installed aplplication).
What PHP library use?
It's a very new API and not much information.
In the Google GData site there is a warning about that "Most newer Google APIs Google Data APIs are not Google Data APIs." and in the google-api-php-client, no examples of this API.
What is the best method for authentication in a cron?
As you can see I am very confuse, can someone help me, please?
Thank you.
1) It will be an installed application unless you will run it in a web server.
2) Use the official library, add the ytanalytics php library. Samples: https://github.com/youtube/yt-samples-php
3) You can do so by getting a refresh token from OAuth2 Playground and setting it in your youtube object.
Here it explains a little more.
And a step by step video.