定制 joomla/google 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

joomla/google

最新稳定版本:1.2.0

Composer 安装命令:

composer require joomla/google

包简介

Joomla Google Package

README 文档

README

Deprecated

The joomla/google package is deprecated with no further updates planned.

Using the Google Package

The Google package is designed to be a straightforward interface for working with various Google APIs. You can find a list of APIs and documentation for each API at https://developers.google.com/products/.

Instantiating Google

Instantiating Google is easy:

use Joomla\Google\Google;

$google = new Google;

This creates a generic Google object that can be used to instantiate objects for specific Google APIs.

Sometimes it is necessary to specify additional options. This can be done by injecting in a Registry object with your preferred options:

use Joomla\Google\Google;
use Joomla\Registry\Registry;

$options = new Registry;
$options->set('clientid', 'google_client_id.apps.googleusercontent.com');
$options->set('clientsecret', 'google_client_secret');

$google = new Google($options);

Accessing the JGoogle APIs

The Google Package divides APIs into two types: data APIs and embed APIs. Data APIs use Joomla\Http to send and receive data from Google. Embed APIs output HTML, JavaScript, and XML in order to embed information from Google in a webpage.

The Google package is still incomplete, but there are five object APIs that have currently been implemented:

Data: Google Calendar, Google AdSense, Google Picasa

Embed: Google Maps, Google Analytics

Once a Google object has been created, it is simple to use it to create objects for each individual API:

$calendar = $google->data('calendar');

or

$analytics = $google->data('analytics');

Using an API

See below for an example demonstrating the use of the Calendar API:

use Joomla\Google\Google;
use Joomla\Registry\Registry;

$options = new Registry;

// Client ID and Client Secret can be obtained  through the Google API Console (https://code.google.com/apis/console/).
$options->set('clientid', 'google_client_id.apps.googleusercontent.com');
$options->set('clientsecret', 'google_client_secret');
$options->set('redirecturi', JURI::current());

$google = new Google($options);

// Get a calendar API object
$calendar = $google->data('calendar');

// If the client hasn't been authenticated via OAuth yet, redirect to the appropriate URL and terminate the program
if (!$calendar->isAuth())
{
	JResponse::sendHeaders();
	die();
}

// Create a new Google Calendar called "Hello World."
$calendar->createCalendar('Hello World');

More Information

The following resources contain more information:Joomla! API Reference, Google Developers Homepage

Installation via Composer

Add "joomla/google": "2.0.*@dev" to the require block in your composer.json and then run composer install.

{
	"require": {
		"joomla/google": "2.0.*@dev"
	}
}

Alternatively, you can simply run the following from the command line:

composer require joomla/google "2.0.*@dev"

统计信息

  • 总下载量: 272
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 17
  • Forks: 14
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2013-02-24