2016-02-08 79 views
1

我想用api創建一個廣告素材。當我發佈object_story_spec參數,我得到這個錯誤'創意規格必須是一個關聯數組(可選json編碼)'object_story_spec規範必須是關聯數組

這是我的json值它是有效的。

{ "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

+0

我解決了我的問題,升級帳戶開發人員到基本帳戶 –

回答

0

應該是這樣的東西。

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, 
     )); 
0

您應該在傳入如下所示的廣告素材之前先登錄$ object_story_spec。

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