如何在我的网站上显示Google Ads(如Facebook)赞助的帖子(不支持html,php api)

时间:2019-04-30 12:50:43

标签: php google-api ads adsense adsense-api

我想通过Google广告获得付款。我想从PHP的Google API获取这些广告。我发现了一些php google api类,但是我不明白如何实现它们。我尝试过的:

https://github.com/googleads/googleads-php-lib
https://github.com/googleads/google-ads-php

我还创建了一个测试文件index.php。看起来像下面的代码:

<?php

session_start();

require_once realpath(dirname(__FILE__) . '/Google/autoload.php');
  $service_url = "https://www.googleapis.com/auth/analytics.readonly";

  $client = new Google_Client();
  $client->setApplicationName("Client_Library_Examples");
  $client->setDeveloperKey("MY_KEY");

  //$service = new Google_Service_Books($client);
  $service = new Google_Service_AdSense($client);

  $key_file_location = "key.json";

  $client->setAuthConfigFile($key_file_location); // path to your json key file
  $client->addScope($service_url); // URL to the service you're planning to use

我不知道如何继续。如何获取json格式的广告?

0 个答案:

没有答案