Posts tagged with google-ads-api

This code is being used on aws lambda for making Google ads client

try:     googleads_client = GoogleAdsClient.load_from_dict(credentials, version="v11",) except GoogleAdsException as e:     print(f"Google Ads Exception: {e.message}") 

Unfortunately this is running into time out issue even if the time is set to 3 minutes. As there is no error, It is not possible to debug the issue. Any experienced developer can share some tips? Thanks alot

I searched some forums about how to prevent sql injection in python and saw that there are ways to use a code like the following:

nome = "'Carlos' , idade = 80" cursor.execute("UPDATE cliente SET nome=%(nome)s WHERE idcliente=13", ({'nome': nome, }))

Most of the examples I see the variable 'cursor.execute' and an execute next to it, I would like to know how to replicate this in the Google ads API.

I want to know if have some 'cursor.execute' in Google Ads API...

I am running google ads and having invalid click issues my ad serve only in Dubai, problem i face my competitor click bomb my ad from UK, FRACE and other countries mostly from Europe and Britain, I excluded all the world expect Dubai but my competitor still able to see my ad and clicking them with some kind of bot till Dawn to Dusk.

I talked with google and they said our system filter invalid clicks but still 30 to 50 percent clicks google consider legit.

I come up with a solution by installing a plugin in WordPress and filtering traffic by filtering URL with "/?gclid=" parameter. But now I have to do it manually.

My question is there any automate rule in WordPress so I can block an IP address automatically if he click on my ad more then a couple of times.

I am trying to run a google app script with Whatsapp business API to send messages to my customers directly from google sheets. The below app runs fine but every time I run it, it sends the message again and again to all customers irrespective of the same msg being sent to the same customer earlier.

Is there a way, I can add a column and update it automatically to record if the message has been sent to this customer in which case skip to the next (just like in mail merge scripts).

I have the below code and a screenshot of the image here

`
const WHATSAPP_ACCESS_TOKEN = "**My whatsapp token**"; const WHATSAPP_TEMPLATE_NAME = "**My template name**"; const LANGUAGE_CODE = "en"; const sendMessage_ = ({   recipient_number,   customer_name,   item_name,   delivery_date, }) => {   const apiUrl = "**My api url**";       const request = UrlFetchApp.fetch(apiUrl, {     muteHttpExceptions: true,     method: "POST",     headers: {       Authorization: `Bearer ${WHATSAPP_ACCESS_TOKEN}`,       "Content-Type": "application/json",     },     payload: JSON.stringify({       messaging_product: "whatsapp",       type: "template",       to: recipient_number,       template: {         name: WHATSAPP_TEMPLATE_NAME,         language: { code: LANGUAGE_CODE },         components: [           {             type: "body",             parameters: [               {                 type: "text",                 text: customer_name,               },               {                 type: "text",                 text: item_name,               },               {                 type: "text",                 text: delivery_date,               },             ],           },         ],       },     }),   });   const { error } = JSON.parse(request);   const status = error ? `Error: ${JSON.stringify(error)}` : `Message sent to ${recipient_number}`;   Logger.log(status); }; const getSheetData_ = () => {   const [header, ...rows] = SpreadsheetApp.getActiveSheet().getDataRange().getDisplayValues();   const data = [];    rows.forEach((row) => {     const recipient = { };     header.forEach((title, column) => {       recipient[title] = row[column];     });     data.push(recipient);   });    return data; }; const main = () => {   const data = getSheetData_();   data.forEach((recipient) => {       const status = sendMessage_({         recipient_number: recipient["Phone Number"].replace(/[^\d]/g, ""),         customer_name: recipient["Customer Name"],         item_name: recipient["Item Name"],         delivery_date: recipient["Delivery Date"],       });   }); };

Using bellow code I can get the access and refresh token:

private const SCOPE                 = 'https://www.googleapis.com/auth/adwords'; private const AUTHORIZATION_URI     = 'https://accounts.google.com/o/oauth2/v2/auth'; private const OAUTH2_CALLBACK_PATH  = ''; private const REDIRECT_URL          = 'http://localhost:3000/google/google-ads/confirmed'; $code           = $request->input('code'); $scope          = $request->input('scope'); $state          = $request->input('state'); $project_token  = $request->input('project_token'); $project_name   = $request->input('project_name'); $account_name   = $request->input('account_name'); $account_id     = $request->input('account_id'); $clientId       = 'my-client-id--kh3el.apps.googleusercontent.com'; $clientSecret   = 'my-clicent-secret4cCm'; $redirectUrl    = self::REDIRECT_URL; $oauth2 = new OAuth2(     [         'clientId'              => $clientId,         'clientSecret'          => $clientSecret,         'authorizationUri'      => self::AUTHORIZATION_URI,         'redirectUri'           => $redirectUrl . self::OAUTH2_CALLBACK_PATH,         'tokenCredentialUri'    => CredentialsLoader::TOKEN_CREDENTIAL_URI,         'scope'                 => self::SCOPE,         // Create a 'state' token to prevent request forgery. See         // https://developers.google.com/identity/protocols/OpenIDConnect#createxsrftoken         // for details.         'state' => sha1(openssl_random_pseudo_bytes(1024))     ] ); // Set the authorization code and fetch refresh and access tokens. $oauth2->setCode($code); $authToken = $oauth2->fetchAuthToken(); $refreshToken   = isset( $authToken['refresh_token'] ) ? $authToken['refresh_token'] : ''; $accessToken    = $oauth2->getAccessToken(); 

now how can I get the emaill address? Is there any way?