當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DfpUser::GetOAuthInfo方法代碼示例

本文整理匯總了PHP中DfpUser::GetOAuthInfo方法的典型用法代碼示例。如果您正苦於以下問題:PHP DfpUser::GetOAuthInfo方法的具體用法?PHP DfpUser::GetOAuthInfo怎麽用?PHP DfpUser::GetOAuthInfo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DfpUser的用法示例。


在下文中一共展示了DfpUser::GetOAuthInfo方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: printf

    $user->SetOAuthInfo($oauthInfo);
    // Request a new OAuth token. Web applications should pass in a callback URL
    // to redirect the user to after authorizing the token.
    $user->RequestOAuthToken();
    // Get the authorization URL for the OAuth token.
    $authorizationUrl = $user->GetOAuthAuthorizationUrl();
    // In a web application, you would redirect the user to the authorization URL
    // and after approving the token they would be redirected back to the
    // callback URL, with the URL parameter "oauth_verifier" added. For desktop
    // or server applications, spawn a browser to the URL and then have the user
    // enter the verification code that is displayed.
    printf("Log in to your DFP account and open the following URL: %s\n", $authorizationUrl);
    print 'After approving the token enter the verification code here: ';
    $stdin = fopen('php://stdin', 'r');
    $verifier = trim(fgets($stdin));
    fclose($stdin);
    // Upgrade the authorized token.
    $user->UpgradeOAuthToken($verifier);
    // An upgraded token does not expire and should be stored and reused for
    // every request to the API.
    $oauthInfo = $user->GetOAuthInfo();
    print "OAuth authorization successful.\n";
    print_r($oauthInfo);
    // Get all ad units.
    $inventoryService = $user->GetService('InventoryService');
    $page = $inventoryService->getAdUnitsByStatement(new Statement('LIMIT 500'));
    // Display number of ad units.
    printf("Found %d ad units.\n", $page->totalResultSetSize);
} catch (Exception $e) {
    print $e->getMessage();
}
開發者ID:RayViljoen,項目名稱:Auto-DFP,代碼行數:31,代碼來源:UseOAuth.php


注:本文中的DfpUser::GetOAuthInfo方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。