-
Notifications
You must be signed in to change notification settings - Fork 518
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Static singletons used everywhere #604
Comments
I'm facing similar problem... @stevebauman did you managed to find a solution for that? |
@norberttech No I haven't unfortunately. I'm considering just using raw HTTP calls to their API instead. Doesn't seem like there's an easy way with this SDK without extending a bunch of classes and overriding a ton of methods. |
yeah, I was thinking the same but it also seems that joelbutcher/facebook-graph-sdk works fine, I just tested fetching campaigns and it works, plus it's not a singleton so multitenancy is doable. $fb = new \Facebook\Facebook([
'app_id' => $authConfig['app_id'],
'app_secret' => $authConfig['app_secret'],
'default_graph_version' => $authConfig['api_version'],
'default_access_token' => 'long_living_access_token',
'http_client_handler' => new GuzzleHttpClient(...), // you can also inject your custom client in case you would like to mock responses
]);
$accountsData = $facebook->get('/me/adaccounts')->getDecodedBody();
$campaignsData = $facebook->get($accountsData['data'][0]['id'] . '/campaigns')->getDecodedBody();
Yeah, in case of any issues with this sdk I'm probably also gonna look into simple http request/response that would return associative arrays. |
I'm working on an application that will facilitate reporting against multiple Meta integrations during the same request, but I quickly discovered that this is will cause issues if you keep one integration in memory and call it later after another one has been initialized. For example:
I thought there would be a way around this by setting the HTTP client inside of the
EventRequest
manually:facebook-php-business-sdk/src/FacebookAds/Object/ServerSide/EventRequest.php
Lines 214 to 217 in f3eb099
But then the singletons are called regardless later on:
facebook-php-business-sdk/src/FacebookAds/Object/ServerSide/EventRequest.php
Lines 309 to 313 in f3eb099
facebook-php-business-sdk/src/FacebookAds/Object/ServerSide/EventRequest.php
Lines 316 to 320 in f3eb099
Why is this the case? Why do all these static PHP singletons need to exist? This will surely cause issues for anyone running a PHP application from memory (Swoole, FrankenPHP, RoadRunner, etc.).
The text was updated successfully, but these errors were encountered: