0

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

我有以下几点:

  • 一个谷歌帐户
  • 在谷歌API控制台购物
  • 启用搜索API,并得到 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):

没有广告商注册了给定的发行

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

我一直在从这个方向入侵到所有方向,现在我开始认为这个API被破坏了。有没有人设法通过Search API for Shopping访问GAN产品Feed?

任何帮助表示赞赏。

回答

0

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

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

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