【问题标题】:Access Google Affiliate Network product feed via the Google Search API for Shopping通过 Google Search API for Shopping 访问 Google Affiliate Network 产品提要
【发布时间】:2012-04-22 22:26:27
【问题描述】:

我想通过 Google 搜索 API 访问我的 Google Affiliate Network 产品供稿以进行购物。我想从我正在开发的后端 Python 库中执行此操作。有人做过这样的事吗?

我有以下几点:

  • Google 帐户
  • 在 Google API 控制台中启用 Search API for Shopping 并获得 一个 API 密钥(用于服务器应用程序)和一个客户端 ID + 客户端密码(用于已安装的应用程序)。
  • 一个 GAN 帐户并获得了 pid。
  • 多个广告客户批准了我,因此我的产品 Feed 中有可用的产品。

OAuth2 Python 代码:

from apiclient.discovery import build
from oauth2client.client import OAuth2WebServerFlow
from oauth2client.tools import run
from oauth2client.django_orm import Storage
from models import CredentialsModel 

storage = Storage(CredentialsModel, 'name', 'GAN Reporting', 'credentials')
credentials = storage.get()

if credentials is None or credentials.invalid == True:
    flow = OAuth2WebServerFlow(
        client_id=MyClientID,
        client_secret=MyClientSecret,
        scope='https://www.googleapis.com/auth/shoppingapi',
        user_agent='cleverblocks/1.0',
        access_type='offline')
    credentials = run(flow, storage)

http = httplib2.Http()
credentials.authorize(http)
client = build('shopping', 'v1', http=http,
    developerKey=MyAPIKey)
resource = client.products()
request = resource.list(source='gan:MyGANPid', country='US')
return request.execute()

运行这个我得到以下错误(HttpError 412):

没有为给定发布商注册的广告商

我用来验证的用户列在 GAN->settings->users 部分。

我从四面八方一直在研究这个问题,以至于我现在开始认为这个 API 坏了。有没有人设法通过 Search API for Shopping 访问 GAN 产品提要?

感谢任何帮助。

【问题讨论】:

    标签: python google-api google-shopping-api google-api-python-client


    【解决方案1】:

    终于让上面的 oAuth 代码工作了。

    缺少的步骤是在 GAN 控制台中的 Subscriptions->Product Feed 下为所有广告商设置 FTP 订阅。我使用了虚拟 FTP 凭据。

    没有这一步你会得到上面的错误。

    【讨论】:

      猜你喜欢
      • 2017-07-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-12
      • 2014-08-26
      • 1970-01-01
      相关资源
      最近更新 更多