Posts tagged with php

I apologize if my question is not strictly about a code issue, but I’m not sure where else to ask for help.

Using the WhatsApp Business API, I can create a catalog and have it displayed in the header of the WhatsApp Business number.

I can also upload products via the API, and these products do appear in the Commerce Manager catalog. However, they remain in the status ‘Item will be reviewed — This item will be reviewed before it can appear in ads or Shops to make sure it complies with our policies. If you've chosen to show this item anywhere, it'll automatically appear once it is approved. We'll let you know if there are any issues.’ for a very long time, sometimes days. And after all this time, they're still stuck in this status.

Below is a small PHP snippet I use to build the array that gets sent to Facebook’s endpoint for product creation, but that’s the only code involved. I haven’t received any notifications about policy compliance issues or anything else that might explain the delay.

$data = [     "name" => $name,     "currency" => "EUR",     "price" => $price,     "image_url" => $image_url,     "retailer_id" => $retailer_id,     "description" => $description,     "url" => $url,     "brand" => $brand ]; $headers = [     "Authorization: Bearer {$auth_token}",     'Content-Type: application/json' ]; POST https://graph.facebook.com/v17.0/<$catalog_id>/products 

I can assure you that all variables are defined, because even in the product detail window, all the data sent via POST is displayed.

Unfortunately, the only link I have to contact Facebook Business Support leads to a page that doesn’t help at all.

I’m wondering if this is a common issue people are currently facing. I’m not sure what else to try at this point.

Thank you for any help you can give me.

I'm facing a problem with custom events sent to Google Analytics. The main problem is that custom sent events are being assigned only to user acquisition and not to traffic acquisition.

I'm sending 2 custom events.

1st event starts the session:

{     "client_id": "435384.2118427612",     "events": [         {             "name": "session_start_test",             "params": {                 "session_id": 1733217977,                 "source": "Test source",                 "medium": "cpc",                 "session_number": 1             },             "timestamp_micros": 1733217976999990         }     ] } 

2nd event send source data:

{     "client_id": "435384.2118427612",     "events": [         {             "name": "custom_event_test",             "params": {                 "session_id": 1733217977,                 "engagement_time_msec": 100,                 "title": "Test title",                 "country": "Estonia",                 "source": "Test source",                 "medium": "cpc",                 "campaign": "test",                 "campaign_source": "Test source",                 "campaign_medium": "cpc",                 "session_number": 2             },             "timestamp_micros": 1733217977000000         }     ],     "user_properties": {         "country": {             "value": "Estonia"         }     } } 

Both events are sent to GA and can be seen inside realtime reporting.

The problem that both of these events still assign source/medium to user acquisition instead of traffic acquisition. I've also tried to send utm_source and utm_medium, but that did not work out. Any ideas where is the problem?

I'm sending both events with PHP curl, using Google Measurement Protocol API.

I'm currently migrating an app that uses the Instagram Basic Display API (api.instagram.com) to the Instagram Graph API (graph.instagram.com), as the Basic Display API will be deprecated on December 4th, 2024.

I’ve read in the official documentation that I need to create a new app of type "Business" in Meta for Developers and request the instagram_business_basic scope to perform the same actions as before.

Current Implementation

For token generation and API calls, my current workflow looks like this:

1. Short-Lived Access Token Generation

// Short-lived token $url = "https://api.instagram.com/oauth/access_token"; $fields = array(   'client_id' => MY_APP_ID,   'client_secret' => MY_APP_SECRET,   'grant_type' => 'authorization_code',   'redirect_uri' => MY_REDIRECT_URI,   'code' => $code ); return call_curl("POST", $url, $fields); 

2. Long-Lived Access Token Exchange

// Long-lived token $url = "https://graph.instagram.com/access_token?grant_type=ig_exchange_token&client_secret=" . MY_APP_SECRET . "&access_token={$token}"; return call_curl("GET", $url); 

3. API Calls

$data = fetchData("https://graph.instagram.com/me/media?fields={$fields}&access_token={$tokenInstagram}"); 

My Concerns

  • The short-lived token generation process appears to still use the endpoint https://api.instagram.com/oauth/access_token. Is this endpoint going to stop working after the Basic Display API deprecation?
  • Although I’ve switched to the Instagram Graph API for token exchange (graph.instagram.com/access_token) and data fetching, I’m worried that the short-lived token endpoint dependency will cause issues post-deprecation.
  • The Graph API Explorer doesn’t list the graph.instagram.com endpoint, and most references online seem to use graph.facebook.com. Should I be using graph.facebook.com instead for Instagram-related API calls?

What I’ve Done So Far

  • I’ve created a new Business-type app in Meta for Developers.
  • I’ve configured the app with the necessary Instagram permissions.
  • The app has been reviewed and approved by Meta.
  • I’ve verified the generated tokens using the Token Debugger tool, and they are associated with the correct Business app.

My Question

Despite these steps, I’m still unsure if my implementation is fully future-proof for the Instagram Graph API.

  1. Am I missing any critical steps or considerations here?
  2. Should I be worried about the short-lived token generation endpoint?
  3. Why isn’t graph.instagram.com listed in the Graph API Explorer, and should I switch to graph.facebook.com for Instagram API calls?

Any guidance or clarification would be greatly appreciated!

I'm running symfony 6 server / php 8.0.8, google ads api V22.0.0. Got dev token/refresh token, and all other infos, and annot run simple example from google and I'm not sure what I'm doing wrong. Here is my code:

use Google\Ads\GoogleAds\Lib\V14\GoogleAdsClientBuilder; use Google\Ads\GoogleAds\Lib\OAuth2TokenBuilder; use Google\Ads\GoogleAds\V14\Services\GoogleAdsServiceClient; use Google\Ads\GoogleAds\V14\Services\SearchGoogleAdsStreamRequest;     $developerToken = 'xxxx';       $clientId = 'yyyy';     $clientSecret = 'zzzz';     $refreshToken = 'dddd';      $loginCustomerId = 'vvvv';            try {         $oAuth2Credential = (new OAuth2TokenBuilder())             ->withClientId($clientId)             ->withClientSecret($clientSecret)             ->withRefreshToken($refreshToken)             ->build();         $googleAdsClient = (new GoogleAdsClientBuilder())             ->withDeveloperToken($developerToken)             ->withOAuth2Credential($oAuth2Credential)             ->withLoginCustomerId($loginCustomerId)             ->build();         $googleAdsServiceClient = $googleAdsClient->getGoogleAdsServiceClient();                  $query = 'SELECT campaign.id, campaign.name FROM campaign ORDER BY campaign.id';                  $stream2 = $googleAdsServiceClient->searchStream($loginCustomerId, $query         );                  foreach ($stream2->iterateAllElements() as $googleAdsRow) {            not reaching this        }     }      catch (\Google\ApiCore\ApiException $e) {         // Gérer les erreurs         $this->_logCall(self::LOG_GOOGLE_ADS, 'ERREUR:',$e->getBasicMessage());     }        

And here is the error:

Error 404 (Not Found)!!1

The requested URL /v14/customers/vvvv/googleAds:searchStream was not found on this server. That’s all we know.

I'm working with the Google Ads API and trying to run the GetCampaigns.php example from the official repository. The authentication works fine, but when I try to execute the searchStream() method to retrieve campaigns, I get warnings about gRPC channels being maxed out, and the process stops. This is the file

The error log shows the following:

 WARNING: All log messages before absl::InitializeLog() is called are written to STDERR I0000 00:00:1727872579.980136   22500 channel.c:277] [Warning] Target upper bound: 1. Current size: 1. I0000 00:00:1727872579.980178   22500 channel.c:280] [Warning] Target googleads.googleapis.com:443 will not be persisted. 

I tried debugging the code, and the execution stops at this line:

$stream = $googleAdsServiceClient->searchStream(     SearchGoogleAdsStreamRequest::build($customerId, $query) ); 

I also tried increasing the number of gRPC channels by setting the following environment variable, but it didn't solve the issue:

putenv('GRPC_DEFAULT_MAX_CHANNELS=10');