Vous pouvez utiliser les méthodes suivantes pour afficher des informations sur un éditeur dans son PublisherProfile.
Obtenir un profil individuel
Vous pouvez utiliser la méthode buyers.publisherProfiles.get pour identifier un éditeur spécifique.
Par exemple, lorsque vous recevez une proposition d'un éditeur, vous pouvez obtenir son PublisherProfile pour en savoir plus.
L'exemple suivant montre comment récupérer un PublisherProfile individuel avec la méthode get :
REST
Requête
GET https://authorizedbuyersmarketplace.googleapis.com/v1/buyers/12345678/publisherProfiles/PP12345?alt=json Authorization: Bearer ACCESS_TOKEN Content-Type: application/json
Réponse
{
"name":"buyers/12345678/publisherProfiles/PP12345",
"displayName":"Mars News",
"logoUrl":"//www.gstatic.com/adx/customerlogos/999221114/0/1234567890.jpg",
"directDealsContact":"advertising@marsnews.com",
"programmaticDealsContact":"advertising@marsnews.com",
"samplePageUrl":"http://www.news.mars/ ",
"overview":"Mars news is the top news organization in the United Federation of Mars, covering a broad range of subjects such as local politics, the interplanetary exchange, and the latest xenoarchaeological discoveries.\n",
"pitchStatement":"Mars News is the premier Mars news network, and the most trusted source of Mars news in the Milky Way. Reach our multicultural and multispecies community of highly educated Martians and friends of Mars from abroad.",
"topHeadlines":[
"Most trusted news source on Mars",
"Journalistic integrity that is recognized across the galaxy",
"Incredible interplanetary reach"
],
"isParent":true
}Java
/* * Copyright 2022 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.api.services.samples.authorizedbuyers.marketplace.v1.buyers.publisherProfiles; import com.google.api.services.authorizedbuyersmarketplace.v1.AuthorizedBuyersMarketplace; import com.google.api.services.authorizedbuyersmarketplace.v1.model.PublisherProfile; import com.google.api.services.samples.authorizedbuyers.marketplace.v1.Utils; import java.io.IOException; import java.security.GeneralSecurityException; import net.sourceforge.argparse4j.ArgumentParsers; import net.sourceforge.argparse4j.inf.ArgumentParser; import net.sourceforge.argparse4j.inf.ArgumentParserException; import net.sourceforge.argparse4j.inf.Namespace; /** * This sample illustrates how to get a publisher profile for the given buyer and publisher profile * ID. */ public class GetPublisherProfiles { public static void execute(AuthorizedBuyersMarketplace marketplaceClient, Namespace parsedArgs) { Long accountId = parsedArgs.getLong("account_id"); String publisherProfileId = parsedArgs.getString("publisher_profile_id"); String name = String.format("buyers/%d/publisherProfiles/%s", accountId, publisherProfileId); PublisherProfile publisherProfile = null; try { publisherProfile = marketplaceClient.buyers().publisherProfiles().get(name).execute(); } catch (IOException ex) { System.out.printf("Marketplace API returned error response::%n%s", ex); System.exit(1); } System.out.printf( "Found publisher profile with ID \"%s\" for buyer account ID '%d'::%n", publisherProfileId, accountId); Utils.printPublisherProfile(publisherProfile); } public static void main(String[] args) { ArgumentParser parser = ArgumentParsers.newFor("GetPublisherProfiles") .build() .defaultHelp(true) .description(("Get a publisher profile for the given buyer and publisher profile ID.")); parser .addArgument("-a", "--account_id") .help( "The resource ID of the buyers resource under which the publisher profile resource " + "is being accessed. This will be used to construct the parent used as a path " + "parameter for the publisherProfiles.get request.") .required(true) .type(Long.class); parser .addArgument("-p", "--publisher_profile_id") .help( "The resource ID of the buyers.publisherProfiles resource that is being accessed. " + "This will be used to construct the name used as a path parameter for the " + "publisherProfiles.get request.") .required(true); Namespace parsedArgs = null; try { parsedArgs = parser.parseArgs(args); } catch (ArgumentParserException ex) { parser.handleError(ex); System.exit(1); } AuthorizedBuyersMarketplace client = null; try { client = Utils.getMarketplaceClient(); } catch (IOException ex) { System.out.printf("Unable to create Marketplace API service::%n%s", ex); System.out.println("Did you specify a valid path to a service account key file?"); System.exit(1); } catch (GeneralSecurityException ex) { System.out.printf("Unable to establish secure HttpTransport::%n%s", ex); System.exit(1); } execute(client, parsedArgs); } }
Lister plusieurs profils d'éditeur
Vous pouvez utiliser la méthode buyers.publisherProfiles.list pour parcourir tous les profils d'éditeurs ou pour trouver un sous-ensemble de profils d'éditeurs à l'aide du paramètre filter.
L'exemple suivant montre comment récupérer une liste de profils d'éditeur avec la méthode list :
REST
Requête
GET https://authorizedbuyersmarketplace.googleapis.com/v1/buyers/12345678/publisherProfiles?pageSize=3&alt=json Authorization: Bearer ACCESS_TOKEN Content-Type: application/json
Réponse
{
"publisherProfiles":[
{
"name":"buyers/12345678/publisherProfiles/PP12345",
"displayName":"Mars News",
"logoUrl":"//www.gstatic.com/adx/customerlogos/999221114/0/1234567890.jpg",
"directDealsContact":"advertising@marsnews.com",
"programmaticDealsContact":"advertising@marsnews.com",
"samplePageUrl":"http://www.news.mars/ ",
"overview":"Mars news is the top news organization in the United Federation of Mars, covering a broad range of subjects such as local politics, the interplanetary exchange, and the latest xenoarchaeological discoveries.\n",
"pitchStatement":"Mars News is the premier Mars news network, and the most trusted source of Mars news in the Milky Way. Reach our multicultural and multispecies community of highly educated Martians and friends of Mars from abroad.",
"topHeadlines":[
"Most trusted news source on Mars",
"Journalistic integrity that is recognized across the galaxy",
"Incredible interplanetary reach"
],
"isParent":true
},
{
"name":"buyers/12345678/publisherProfiles/PP54321",
"displayName":"Red Planet",
"domains":[
"redplanet.mars",
"luxurytravel.mars"
],
"logoUrl":"//www.gstatic.com/adx/customerlogos/877235551/1/2165203912871.jpg",
"directDealsContact":"advertising@redplanet.mars",
"programmaticDealsContact":"advertising@redplanet.mars",
"samplePageUrl":"https://redplanet.mars/travel",
"overview":"Red Planet is dedicated to promoting Mars tourism with extensive travel guides to help spacefarers find the best cultural, historical, or natural travel destinations across the planet.\n",
"pitchStatement":"Find your audience of intrepid space explorers today.",
"topHeadlines":[
"Leader in rapidly growing Mars travel industry",
"Travel guides trusted across the galaxy",
"Quality travel guides for the adventurous"
]
},
{
"name":"buyers/12345678/publisherProfiles/PP67890",
"displayName":"Mars Media Ltd",
"isParent":true
}
],
"nextPageToken":"CAMQ7rnIhufQ9gIY7rnIhufQ9gI="
}Java
/* * Copyright 2022 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.api.services.samples.authorizedbuyers.marketplace.v1.buyers.publisherProfiles; import com.google.api.services.authorizedbuyersmarketplace.v1.AuthorizedBuyersMarketplace; import com.google.api.services.authorizedbuyersmarketplace.v1.model.ListPublisherProfilesResponse; import com.google.api.services.authorizedbuyersmarketplace.v1.model.PublisherProfile; import com.google.api.services.samples.authorizedbuyers.marketplace.v1.Utils; import java.io.IOException; import java.security.GeneralSecurityException; import java.util.List; import net.sourceforge.argparse4j.ArgumentParsers; import net.sourceforge.argparse4j.inf.ArgumentParser; import net.sourceforge.argparse4j.inf.ArgumentParserException; import net.sourceforge.argparse4j.inf.Namespace; /** This sample illustrates how to list publisher profiles for a given buyer account ID. */ public class ListPublisherProfiles { public static void execute(AuthorizedBuyersMarketplace marketplaceClient, Namespace parsedArgs) { Long accountId = parsedArgs.getLong("account_id"); Integer pageSize = parsedArgs.getInt("page_size"); String parentBuyerName = String.format("buyers/%s", accountId); String pageToken = null; System.out.printf("Found publisher profiles for buyer Account ID '%d'::%n", accountId); do { List<PublisherProfile> publisherProfiles = null; try { ListPublisherProfilesResponse response = marketplaceClient .buyers() .publisherProfiles() .list(parentBuyerName) .setFilter(parsedArgs.getString("filter")) .setPageSize(pageSize) .setPageToken(pageToken) .execute(); publisherProfiles = response.getPublisherProfiles(); pageToken = response.getNextPageToken(); } catch (IOException ex) { System.out.printf("Marketplace API returned error response::%n%s", ex); System.exit(1); } if (publisherProfiles == null) { System.out.println("No publisher profiles found."); } else { for (PublisherProfile publisherProfile : publisherProfiles) { Utils.printPublisherProfile(publisherProfile); } } } while (pageToken != null); } public static void main(String[] args) { ArgumentParser parser = ArgumentParsers.newFor("ListPublisherProfiles") .build() .defaultHelp(true) .description(("Lists publisher profiles associated with the given buyer account.")); parser .addArgument("-a", "--account_id") .help( "The resource ID of the buyers resource under which the publisherProfiles resource " + "is being accessed. This will be used to construct the parent used as a path " + "parameter for the publisherProfiles.list request.") .required(true) .type(Long.class); parser .addArgument("-f", "--filter") .help( "Query string to filter publisher profiles. If no filter is specified, all " + "publisher profiles will be returned. By default, no filter will be set by this " + "example."); parser .addArgument("-p", "--page_size") .help( "The number of rows to return per page. The server may return fewer rows than " + "specified.") .setDefault(Utils.getMaximumPageSize()) .type(Integer.class); Namespace parsedArgs = null; try { parsedArgs = parser.parseArgs(args); } catch (ArgumentParserException ex) { parser.handleError(ex); System.exit(1); } AuthorizedBuyersMarketplace client = null; try { client = Utils.getMarketplaceClient(); } catch (IOException ex) { System.out.printf("Unable to create Marketplace API service::%n%s", ex); System.out.println("Did you specify a valid path to a service account key file?"); System.exit(1); } catch (GeneralSecurityException ex) { System.out.printf("Unable to establish secure HttpTransport::%n%s", ex); System.exit(1); } execute(client, parsedArgs); } }