私を助けてください....
Google AdSense API を使用して、PHP から収益を得たいと考えています。
しかし、サンプル コードは機能しません。
PUTTY - SSH connect
Install 'Composer'
php -r "if (hash_file('SHA384', 'composer-setup.php') === 'aa96f26c2b67226a324c27919f1eb05f21c248b987e6195cad9690d5c1ff713d53020a02ac8c217dbf90a7eacc9d141d') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
「PHP 用 Google API クライアント ライブラリ」をインストールします。
php composer.phar には google/apiclient:^2.0 が必要です
PHP 用の AdSense Management API サンプルをサーバーにコピーします。
https://github.com/googleads/googleads-adsense-examples/tree/master/php-clientlib-1.x/v1.x
client_secrets.json を変更する
クライアント ID、クライアント シークレット、およびリダイレクト URL
- サンプルをブラウザーで開きます。サンプルコードはしかし、動作していません
……T_T
- 私は2週間の間、さまざまな方法を試しました
私の推測では、パスが問題です。しかし、それは間違っています。
[adsense-sample.php - 変更前]
/************************************************
ATTENTION: Change this path to point to your
client library installation!
************************************************/
set_include_path('/path/to/clientlib' . PATH_SEPARATOR . get_include_path());
require_once 'Google/Client.php';
require_once 'Google/Service/AdSense.php';
// Autoload example classes.
function __autoload($class_name) {
include 'examples/' . $class_name . '.php';
}
↓</p>
[adsense-sample.php - 後]
require_once __DIR__.'/vendor/autoload.php';
require_once 'templates/base.php';
require_once 'examples/CollateReportData.php';
require_once 'examples/FillMissingDatesInReport.php';
require_once 'examples/GenerateReport.php';
require_once 'examples/GenerateReportWithPaging.php';
require_once 'examples/GenerateSavedReport.php';
require_once 'examples/GetAccountTree.php';
require_once 'examples/GetAllAccounts.php';
require_once 'examples/GetAllAdClients.php';
require_once 'examples/GetAllAdUnits.php';
require_once 'examples/GetAllAdUnitsForCustomChannel.php';
require_once 'examples/GetAllAlerts.php';
require_once 'examples/GetAllCustomChannels.php';
require_once 'examples/GetAllCustomChannelsForAdUnit.php';
require_once 'examples/GetAllDimensions.php';
require_once 'examples/GetAllMetrics.php';
require_once 'examples/GetAllSavedAdStyles.php';
require_once 'examples/GetAllSavedReports.php';
require_once 'examples/GetAllUrlChannels.php';
私を助けてください...