Saturday, February 25, 2017

Facebook Marketing API, Version 2.8 Error Despite 2.8 In Composer.json,facebook,php,json,facebook

I am programming a Marketing-API for facebook and am running into the following error:

Fatal error: Uncaught exception 'FacebookAdsHttpExceptionAuthorizationException' with message '(#2635) You are calling a deprecated version of the Ads API. Please update to the latest version: v2.8.' in MY FOLDER/vendor/facebook/php-ads-sdk/src/FacebookAds/Http/Exception/:163

"require": "facebook/php-sdk-v4" : "~5.0", "facebook/php-ads-sdk": "2.8."

Within the app folder (which I upload to a private server, from /localhost/~my user name/some directory/, henceforth referred to as MY FOLDER) I have two php files and as well as the sdks (facebook & facebook-ads) located in MY FOLDER/vendor. Here are the php files:

'000000000000', // censored 'app_secret' => '000000000000', // censored ); $helper = $fb->getRedirectLoginHelper(); $accessToken = $helper->getAccessToken(); // This is actually wrapped in a try-catch control group // I have left it out for this question, as there are no problems // in this respect and the clauses are really long. Api::init( $app_id, $app_key, $_SESSION'facebook_access_token' ); $campaign = new Campaign('000000000000'); // censored try $campaign->read(array( CampaignFields::ID, CampaignFields::NAME, CampaignFields::OBJECTIVE, )); catch(FacebookExceptionsFacebookResponseException $e) // error with Graph API exit; catch(FacebookExceptionsFacebookSDKException $e) // error with Facebook SDK exit; ?>

The error occurs when trying to call $campaign->read(array(...)). The SDK returns the error above together with the tracking:

Stack trace: #0 API-FOLDER/Http/ (217): FacebookAdsHttpExceptionRequestException::create(Array, 400) #1 API-FOLDER/Http/ (282): FacebookAdsHttpClient->sendRequest(Object(FacebookAdsHttpRequest)) #2 API-FOLDER/ (152): FacebookAdsHttpRequest->execute() #3 API-FOLDER/ (194): FacebookAds in API-FOLDER/Http/Exception/ on line 163

Note the demand in the error:..Ads API. Please update to the latest version: v2.8. But I have done this. Can someone please tell me, what on Earth is going on?

I have found a(n annoying) solution. I went to github and manually downloaded the latest version.

This is ridiculous. I followed the official installation instructions on -api/sdks (create file incl. explicit version details ?> execute terminal command php install -no-dev). I don't see why this does not work.

Has anyone else encountered this problem? Or am I one of the few, for whom automatic installation did not lead to the right version?

I think this might have to do with the login part. When initializing the Facebook class here,

$fb = new Facebook( 'app_id' => '000000000000', // censored facebook marketing best practices 'app_secret' => '000000000000', // censored );

you did not specify the API version to use - so it falls back to the lowest API version your app can use. Likely that messes up things later when you use the resulting token to make calls to the Marketing API.

$fb = new Facebook( 'app_id' => '000000000000', // censored 'app_secret' => '000000000000', // censored 'default_graph_version' => 'v2.8', );

Oleg here! I will try to serve you best Q&A related with programming. Hope that you will enjoy.

Please note that I'm not asking how to append texts at the end of the file. I'm asking how to prepend texts to the beginning of file. let handle = try FileHandle(forWritingTo: someFile) //handle.seekToEndOfFile() // This is for appending..

No comments:

Post a Comment