2011-04-25 5 views
0

내 웹 사이트를 연결하여 Google 애드워즈에 연결하여 내 사이트의 제품에 따라 광고 및 캠프를 만들려고합니다. 직접 컬 요청을 보내서 연결을 시도하고 수신 된 SOAP 응답을 구문 분석했습니다. 그러나 각 요청에 대해 너무 복잡해지고 있습니다. 그래서 나는 Google Code에서 제공되는 PHP 클라이언트 라이브러리를 사용해 보았습니다. 그러나 예제 중 어느 것도 올바르게 작동하지 않습니다. 나는 auth.ini 파일에 사용자 계정 정보를 변경 여전히 예를 excecuting에이 Google Adword PHP 클라이언트 라이브러리가 호스트에 연결할 수 없습니다.

이 authToken에 가져 오지 못했습니다 말한다 파일. 이유 : 호스트 '에 연결할 수 없습니다.

다른 서버에서 스크립트를 실행했지만 여전히 동일한 오류가 발생했습니다. 다음

Google 애드워즈의 모든 광고를 가져올 코드이며,이

DEFAULT_SERVER = "HTTPS 클라이언트 라이브러리

$path = dirname(__FILE__) . '/../../src'; 
set_include_path(get_include_path() . PATH_SEPARATOR . $path); 

require_once 'Google/Api/Ads/AdWords/Lib/AdWordsUser.php'; 

try { 
    // Get AdWordsUser from credentials in "../auth.ini" 
    // relative to the AdWordsUser.php file's directory. 
    $user = new AdWordsUser(); 

    // Log SOAP XML request and response. 
    $user->LogDefaults(); 

    // Get the AdGroupAdService. 
    $adGroupAdService = $user->GetAdGroupAdService(); 

    $adGroupId = (float) '01'; 

    // Create selector. 
    $selector = new Selector(); 
    $selector->fields = array('Id', 'AdGroupId', 'Status'); 
    $selector->ordering = array(new OrderBy('Id', 'ASCENDING')); 

    // Create predicates. 
    $adGroupIdPredicate = new Predicate('AdGroupId', 'IN', array($adGroupId)); 
    // By default disabled ads aren't returned by the selector. To return them 
    // include the DISABLED status in a predicate. 
    $statusPredicate = 
     new Predicate('Status', 'IN', array('ENABLED', 'PAUSED', 'DISABLED')); 
    $selector->predicates = array($adGroupIdPredicate, $statusPredicate); 

    // Get all ads. 
    $page = $adGroupAdService->get($selector); 

    // Display ads. 
    if (isset($page->entries)) { 
    foreach ($page->entries as $adGroupAd) { 
     printf("Ad with id '%s', type '%s', and status '%s' was found.\n", 
      $adGroupAd->ad->id, $adGroupAd->ad->AdType, $adGroupAd->status); 
    } 
    } else { 
    print "No ads were found.\n"; 
    } 
} catch (Exception $e) { 
    echo 'Inside catch exception'; 
    print $e->getMessage(); 
} 

에서와 settings.ini 파일의 예제 파일입니다 : //adwords-sandbox.google.com "

; AUTH_SERVER = "<SERVER>"

auth.ini 파일에서 Google 계정의 사용자 이름과 비밀번호가 올바르게 설정되었습니다.

이 문제가 해결 될 수 있도록 도와 줄 사람이 있습니까?

감사

+0

사용중인 코드 중 일부를 표시하십시오. 어떤 호스트에 연결하려고합니까? 도달 할 수 있습니까? –

답변

0

은 인증 요청이 전송되는 위치를 나타냅니다 AUTH_SERVER 설정하지 DEFAULT_SERVER,입니다. 이 값은 settings.ini의 맨 아래에 있어야하지만 일반적으로 주석 처리되어 기본 설정 인 https://www.google.com이 사용됩니다. AUTH_SERVER이 주석 처리되었으며 https://www.google.com에 연결할 수 있는지 확인해야합니다.

+0

예 인증 서버 설정이 주석 처리되었으며 기본 서버를 가리 킵니다. – Goysar

관련 문제