Search code examples
phpfacebookfacebook-graph-apifacebook-php-sdkfacebook-marketing-api

Can't get AdCreative ObjectStorySpec


I'm using Facebook Marketing Api and I can not retrieve AdCreative object's object_story_spec field as described in docs here: https://developers.facebook.com/docs/marketing-api/reference/ad-creative

Though object_story_spec field itself seems to be a perfectly OK:

 $creative = new AdCreative($ad->creative['id']);
 $creativeData = $creative
                   ->read(['object_story_spec', 'object_story_id'])
                   ->getData();

 // $creativeData['object_story_id'] contains an ID like 99999999999_99999999999,
 // $creativeData['object_story_spec'] is null

I tried to run query with curl, same result:

curl -G \
  -d 'fields=object_story_spec' \
  -d 'fields=object_story_id' \
  -d 'access_token=MYTOKEN' \
  https://graph.facebook.com/v2.6/123456789

The result does not contain object_story_spec at all:

{"object_story_id":"99999999999_99999999999","id":"123456789"}

A few more things:

  • The token is authorized to perform actions.
  • The ad is active.
  • object_story_spec is definitely a correct field since querying a non-existent field results in error

Best regards, Alexander

P.S. I submitted a bug report to FB: https://developers.facebook.com/bugs/1721287254755608/


Solution

  • object_story_spec can be read back from an adcreative when it was used in the creation of that adcreative. If an object is created first it can be linked to an adcreative using object_story_id but that does not populate object_story_spec, the field will be NULL or not returned at all from Graph API.

    object_story_spec is a helper method for creating objects (e.g. page posts) inline to creating a ad creative. See https://developers.facebook.com/docs/marketing-api/reference/ad-creative#Creating for more info on these fields and try out one of the example code snippets to see object_story_spec returned on a read request when it is used on the create request.