Posts tagged with php

Hi I want to use WhatsApp business API in my web application. I have tested it in postman.

Whenever run sample curl code when available in Facebook business page under WhatsApp tab, It run successfully with temporary access token and message delivered to recipient with Facebook saved template. But when I send only text message to recipient then API response become success with message Id but message not yet deliver to recipient.

My curl code sample given bellow

curl --location --request POST 'https://graph.facebook.com/v13.0/106433498743301/messages' \ --header 'Authorization: Bearer EAAOw8oNtvXkBAKk89CqJtyusjxk7c7qGSNS0quxqeZBRtjE5MYwZCK0USeGGLV4n56qNAuaRoRWZA2oCIS8zcz6U5UZAtQCOb6YQnjuXZBfLnyZAwsOZBpASpnNOvvz29T0Jn0aXgZAdo9VKmBv0CkNYuOeb1I7X0GZCEwLHPZBFpfOCj4K3S9CMPjBfYR5Jog06LC95P7UgCr5Fy2nqbRM5Ys' \ --header 'Content-Type: application/json' \ --data-raw '{ "messaging_product": "whatsapp", "preview_url": false, "recipient_type": "individual", "to": "xxxxxxx150", "type": "text", "text": { "body": "Test message" } }' 

I am looking for the equivalents of Adwords API in the new Google ads API in PHP.

For example, the equivalent of

use Google\AdsApi\AdWords\v201809\cm\AgeRange; 

is

use Google\Ads\GoogleAds\V10\Common\AgeRangeInfo; 

But I can't find the exact equivalents for those for example:

use Google\AdsApi\AdWords\v201809\cm\GeoTargetTypeSetting; use Google\AdsApi\AdWords\v201809\cm\GeoTargetTypeSettingNegativeGeoTargetType; use Google\AdsApi\AdWords\v201809\cm\GeoTargetTypeSettingPositiveGeoTargetType; 

Do you know any translators from google adwords to google ads?

I want to update our code for the new Google Ads API but I cant find the API Center in Google Ads Dashboard with the main account.

When I open the url to API Center than came this message: Only administrative account users have access to the API Center. For more information, see the API login guide

Has anyone a idea or is there another way to get the Developer Token?

I get the error :

{   "message": "The caller does not have permission",   "code": 7,   "status": "PERMISSION_DENIED",   "details": [     {       "@type": "type.googleapis.com\/google.ads.googleads.v10.errors.GoogleAdsFailure",       "errors": [         {           "errorCode": {             "authorizationError": "USER_PERMISSION_DENIED"           },           "message": "User doesn't have permission to access customer. Note: If you're accessing a client customer, the manager's customer id must be set in the 'login-customer-id' header. See https:\/\/developers.google.com\/google-ads\/api\/docs\/concepts\/call-structure#cid"         }       ],       "requestId": "asds33ad3sdadad334"     }   ] } 

and the code I get from here : https://developers.google.com/google-ads/api/docs/reporting/example

what I need to do with login-customer-id ?

I'm trying to get a list of all campaigns using the Google Ads API. To do this, I use an example from the google-ads-php library, but this code does not work for me. What's weird is that the foreach loop doesn't even run and I don't see the output of var_dump. Can anyone suggest me what I'm doing wrong? Or give a link to an example with working code?

My PHP Symfony class code:

    class CheckController extends AbstractController{     /**      * @Route("/check", name="check")      */     public function index(): Response{         $config = $this->getParameter('kernel.project_dir') . '/google_ads_php.ini';         if (!is_file($config)) return $this->json([$config]);         $oAuth2Credential = (new OAuth2TokenBuilder())             ->fromFile($config)             ->build();         $googleAdsClient = (new GoogleAdsClientBuilder())             ->fromFile($config)             ->withOAuth2Credential($oAuth2Credential)             ->build();         try {             self::runExample(                 $googleAdsClient,                 'xxxxxxxxxx'             );         } catch (GoogleAdsException $googleAdsException) {             printf(                 "Request with ID '%s' has failed.%sGoogle Ads failure details:%s",                 $googleAdsException->getRequestId(),                 PHP_EOL,                 PHP_EOL             );             foreach ($googleAdsException->getGoogleAdsFailure()->getErrors() as $error) {                 /** @var GoogleAdsError $error */                 printf(                     "\t%s: %s%s",                     $error->getErrorCode()->getErrorCode(),                     $error->getMessage(),                     PHP_EOL                 );             }             exit(1);         } catch (ApiException $apiException) {             printf(                 "ApiException was thrown with message '%s'.%s",                 $apiException->getMessage(),                 PHP_EOL             );             exit(1);         }         $test = self::runExample($googleAdsClient, '1138211281');         foreach ($test->iterateAllElements() as $googleAdsRow) {             echo '<pre>';                 var_dump($googleAdsRow->getCampaign()->getId());             echo '</pre>';         }         /*echo '<pre>';                 var_dump($test);         echo '</pre>';*/         foreach ($test->iterateAllElements() as $googleAdsRow) {             /** @var GoogleAdsRow $googleAdsRow */             var_dump($googleAdsRow->getCampaign()->getId());         }         /*return $this->render('base.html.twig', [             'test' => $test         ]);*/          return $this->json([              'message' => 'Welcome to your new controller!',              'path' => 'src/Controller/CheckController.php',          ]);     }     /**      * @param GoogleAdsClient $googleAdsClient      * @param int $customerId      * @return void      * @throws ApiException      */     public static function runExample(GoogleAdsClient $googleAdsClient, int $customerId){         $googleAdsServiceClient = $googleAdsClient->getGoogleAdsServiceClient();         // Creates a query that retrieves all campaigns.         $query = 'SELECT campaign.id, campaign.name FROM campaign ORDER BY campaign.id';         // Issues a search stream request.         /** @var GoogleAdsServerStreamDecorator $stream */         $stream = $googleAdsServiceClient->searchStream($customerId, $query);         // Iterates over all rows in all messages and prints the requested field values for         // the campaign in each row.         foreach ($stream->iterateAllElements() as $googleAdsRow) {             /** @var GoogleAdsRow $googleAdsRow */             printf(                 "Campaign with ID %d and name '%s' was found.%s",                 $googleAdsRow->getCampaign()->getId(),                 $googleAdsRow->getCampaign()->getName(),                 PHP_EOL             );         }         return $stream;     } }