使用 Google 广告 API PHP 没有作曲家的客户端?

Use Google Ads API PHP Client without composer?

是否可以在不使用作曲家的情况下使用 Google 的 API?使用共享托管 Web 服务器时,通常无法使用 composer。

https://github.com/googleads/googleads-php-lib/blob/master/README.md

我花了几天时间才找到这个问题的解决方案。

首先,不要获取最新的 Google API PHP 客户端。

2.x 版本开始使用 Composer,坦率地说,它们也开始变得太大而无法上传到共享主机。我相信房东喜欢这样。对于某些人,您必须付费才能获得 PHP 客户。

上传 PHP 客户端,是的,但没有 Composer 的两年旧版本:google-api-php-client v1.1.8。下载 zip 文件,但您只需将此处看到的内容上传到名为:Google

的文件夹下

接下来,请按照这篇文章 PHP server-side YouTube V3 OAuth API video upload guide 作为您的向导。他使用的是更旧的版本,但忽略它。本文将带您完成它。这是一个救生员。

我不知道为什么我无法让 autoload.php 与其 spl_autoload_register('google_api_php_client_autoload'); 一起工作。现在,我只是通过反复试验确定我需要什么,并在我的代码开头包含以下 'require statements':

<?php

require_once $_SERVER['DOCUMENT_ROOT'].'/src/Google/autoload.php';

require_once $_SERVER['DOCUMENT_ROOT'].'/src/Google/Config.php';

require_once $_SERVER['DOCUMENT_ROOT'].'/src/Google/Auth/Abstract.php';

require_once $_SERVER['DOCUMENT_ROOT'].'/src/Google/Auth/OAuth2.php';

require_once $_SERVER['DOCUMENT_ROOT'].'/src/Google/Http/Request.php';

require_once $_SERVER['DOCUMENT_ROOT'].'/src/Google/Utils.php';

require_once $_SERVER['DOCUMENT_ROOT'].'/src/Google/Client.php';

require_once $_SERVER['DOCUMENT_ROOT'].'/src/Google/Service/YouTube.php';

include_once($_SERVER['DOCUMENT_ROOT'].'/src/CookieAPI.php');

session_start();

到了!

你赢了!