Im新到Google adwords - My client center。我有一個網站,用Yii框架查看所有MCC廣告系列,廣告組,廣告等。它工作正常。無效谷歌AdWords帳戶顯示錯誤
我的問題是,如果麥克電子郵件或密碼或客戶端ID無效,它會顯示錯誤,如下面的代碼。
Failed to get authToken. Reason: BadAuthentication
$response = $this->Login();
095 $fields = $this->ParseResponse($response);
096 if (array_key_exists('Error', $fields)) {
097 $error = $fields['Error'];
098 if (array_key_exists('Info', $fields)) {
099 $error .= ': ' . $fields['Info'];
100 }
101 $url = array_key_exists('Url', $fields) ? $fields['Url'] : NULL;
102 $captchaToken = array_key_exists('CaptchaToken', $fields) ?
103 $fields['CaptchaToken'] : NULL;
104 $captchaUrl = array_key_exists('CaptchaUrl', $fields) ?
105 $fields['CaptchaUrl'] : NULL;
106 throw new AuthTokenException($error, $url, $captchaToken, $captchaUrl);
107 } else if (!array_key_exists('Auth', $fields)) {
108 throw new AuthTokenException('Unknown');
109 } else {
110 return $fields['Auth'];
111 }
112 }
113
114 /**
115 * Makes the client login request and stores the result.
116 * @return string the response from the ClientLogin API
117 * @throws AuthTokenException if an error occurs during authentication
118 */
但我想顯示錯誤爲「您的帳戶無效」。請通知我在哪裏寫條件來檢查帳戶是否有效。
我對此沒有太多的想法。我搜索了google adwords api客戶端庫,發現以下「http://code.google.com/p/google-api-adwords-php/downloads/list」。之後,下載了aw_api_php_lib_3.2.2.tar.gz並將該代碼放置在「mysite/protected /」文件夾中。我修改了「mysite/protected/adwords/src/Google/Api/Ads/AdWords/auth.ini」文件中的配置。
在意見文件[mysite的/保護/視圖/網站/ view.php],我已經叫AdWords的功能,
Yii::import('application.adwords.*');
require_once('examples/v201206/BasicOperations/GetCampaigns.php')
$user = new AdWordsUser();
$user->LogAll();
$result_camp = GetCampaignsExample($user);
它返回的所有活動。但是,如果我提供了錯誤的配置細節,它會顯示上述錯誤[無法獲得authToken。原因:BadAuthentication]。我想以指定的格式顯示錯誤。請指教。
我髒的修復將是趕上AuthTokenException exceptoins和顯示他們很好..這是一個插件或您的代碼引發錯誤? – DarkMukke 2013-02-21 12:44:05
,我必須猜測它是哪個插件嗎? – DarkMukke 2013-02-21 15:01:41
@DarkMukke請參閱上面的更多信息。我不知道是哪個拋出錯誤,可能是Google adwords應用程序出錯。如果我錯了,請糾正我。謝謝 – lifeline 2013-02-22 04:36:12