0

Create and publish offers on Facebook page using Facebook PHP SDK.

I have implemented the SDK as provided in documentation and successuly created the offer and that API is returning offer id as described. When I run the publish offer API in my case. '/{offer_id}/nativeofferviews' that is showing me this.

"Fatal error: Uncaught exception 'FacebookAds\Http\Exception\AuthorizationException' with message '(#1) An unknown error occurred'"

and there is no offer on my page also.

Here is the code I am trying for publish offer on page.

Api::init(
  'app_id', // App ID
  'secret',
  'Access_Token' // Your user access token
);
//);
$params = array(
  'message' => 'This is a offer',
  'photos' => array(
       'photo_id'

  ),
  'published' => true,
  'published_ads' => true

);
$data = Api::instance()->call(
  '/offer_id/nativeofferviews',
  RequestInterface::METHOD_POST,
  $params)->getContent();

Output should be According to documentation.

success: bool,
native_offer_view: numeric string,
post: numeric string,
photos: List [
numeric string
],
videos: List [
numeric string
],
}
  • Are you positive your access token has the correct permissions? Sometimes you get an "Unknown error" if your token is incorrect. – LucyTurtle Apr 16 '19 at 14:15
  • Yes access token has permission because I was facing the permission issue and I created new account with permission and used that token for this.. now permission issue resolved but that shows "unknown error" – M Usman Tahir Apr 16 '19 at 15:51

1 Answers1

0

According to the documentation: "Only one of published_ads and published should be specified".

So make sure to get rid of whichever is the extra.

Link to documentation page.

LucyTurtle
  • 1,043
  • 1
  • 17
  • 37