Ugur Gungezerler February 2016

object_story_spec spec must be an associative array

I wanna create a creative with api. When i post object_story_spec parameter, i got this error 'Creative spec must be an associative array (optionally json-encoded)'

this is my json value it is valid.

{ "page_id" : "103830656322074", "link_data": { "call_to_action": {"type":"LEARN_MORE","value":{"link":"facebook.com/"}}, "caption": "Reklam #1", "name": "Reklam #1", "link": "facebook.com/", "message": "facebook.com/" }}

developers.facebook.com/docs/marketing-api/reference/ad-creative#Creating

Answers


Nadeem0035 February 2016

It should be like something.

object_story_spec={ 
                    "page_id": "<PAGE_ID>", 
                    "video_data": { 
                      "call_to_action": {"type":"LIKE_PAGE","value":{"page":"<PAGE_ID>"}}, 
                      "description": "try it out", 
                      "image_url": "<THUMBNAIL_URL>", 
                      "video_id": "<VIDEO_ID>" 
                    } 
                  }


Or

$object_story_spec = new ObjectStorySpec();
        $object_story_spec->setData(array(
            ObjectStorySpecFields::PAGE_ID => <PAGE_ID>,
            ObjectStorySpecFields::LINK_DATA => <LINK_DATA>,
        ));

 $creative = new AdCreative(null, 'ad_Acount_id');
        $creative->setData(array(
            AdCreativeFields::NAME => 'Sample Creative',
            AdCreativeFields::OBJECT_STORY_SPEC => $object_story_spec,
        ));

Post Status

Asked in February 2016
Viewed 1,437 times
Voted 12
Answered 1 times

Search




Leave an answer