Eir*_*rik 3 php shared-hosting composer-php google-ads-api
是否可以在不使用作曲家的情况下使用 Google 的 API?使用共享托管 Web 服务器时,通常无法使用 Composer。
https://github.com/googleads/googleads-php-lib/blob/master/README.md
我花了几天时间才找到解决这个问题的方法。
首先,不要获取最新的 Google API PHP Client。
2.x 版本开始使用 Composer,坦率地说,它们也开始变得太大而无法上传到共享主机。我敢肯定,主人喜欢这样。对于某些人,您必须付费才能获得 PHP 客户端。
上传 PHP 客户端,是的,但是没有 Composer 的两年旧版本:google-api-php-client v1.1.8。下载 zip 文件,但您只需将您在此处看到的内容上传到名为:Google 的文件夹下
接下来,跟随这篇文章,PHP 服务器端 YouTube V3 OAuth API 视频上传指南,作为您的指南。他使用的是更旧的版本,但请忽略它。这篇文章将带您度过难关。这是一个救命稻草。
我不知道为什么我不能让 autoload.php 使用它的spl_autoload_register('google_api_php_client_autoload');. 现在,我只是通过反复试验确定我需要什么,并在我的代码开头包含以下“要求语句”:
<?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();
Run Code Online (Sandbox Code Playgroud)
那里!
你赢了!