請幫助我......'Google AdSense API'的PHP示例代碼不起作用
我想使用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');"
我nstall '谷歌API客戶端庫PHP'
PHP composer.phar要求谷歌/ apiclient:^ 2.0
複製AdSense Management API的樣本PHP到你的服務器。
https://github.com/googleads/googleads-adsense-examples/tree/master/php-clientlib-1.x/v1.x
修改的client_secrets.json
客戶端ID,客戶端密鑰和重定向URL
- 打開示例在瀏覽器中。示例代碼,但不工作
- 我試過很多不同的方式,而2周
...... T_T
我的猜測是,路徑是一個問題。但這是錯誤的。
[站長-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';
}
↓
[站長-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';
請幫我...
任何錯誤,警告或類似的東西? – Viney