コード例 #1
0
        public async Task PublishPhotoAdAsync()
        {
            var request = new AdCreativeCreatingRequest
            {
                ObjectStorySpec = new ObjectStorySpec
                {
                    PageId   = TestsBase.PageId,
                    LinkData = new LinkData
                    {
                        Call2Action = new Call2Action
                        {
                            Type = Call2ActionType.LEARN_MORE
                        },
                        Caption     = "LARY.ME",
                        Description = "Description of photo ad.",
                        Headline    = "Headline of Photo Ad",
                        Link        = TestsBase.Link,
                        Message     = Guid.NewGuid().ToString("N")
                    }
                }
            };

            var response = await AdCreativePublisher.PublishPhotoAdAsync(TestsBase.TestPicturePath, request, TestsBase.AdAccountId, TestsBase.AccessToken, TestsBase.PageAccessToken, true);

            Assert.IsTrue(response.Code == ResponseCode.SUCCESS, response.ReasonPhrase ?? String.Empty);

            var jobj = JObject.Parse(response.Data);

            Assert.IsTrue(jobj["success"] != null && Boolean.Parse(jobj["success"].ToString()) == true);
        }
コード例 #2
0
        public async Task PublishVieoAdWithCustomCoverAsync()
        {
            var request = new AdCreativeCreatingRequest
            {
                ObjectStorySpec = new ObjectStorySpec
                {
                    PageId    = TestsBase.PageId,
                    VideoData = new VideoData
                    {
                        Call2Action = new Call2Action
                        {
                            Type  = Call2ActionType.LEARN_MORE,
                            Value = new Call2ActionValue
                            {
                                Link = TestsBase.Link
                            }
                        },
                        Headline = "Headline of Video Ad With Custom Cover",
                        Message  = Guid.NewGuid().ToString("N")
                    }
                }
            };

            var response = await AdCreativePublisher.PublishVideoAdAsync(TestsBase.TestVideoPath, TestsBase.TestPicturePath, request, TestsBase.AdAccountId, TestsBase.AccessToken, TestsBase.PageAccessToken, true);

            Assert.IsTrue(response.Code == ResponseCode.SUCCESS, response.ReasonPhrase ?? String.Empty);

            var jobj = JObject.Parse(response.Data);

            Assert.IsTrue(jobj["success"] != null && Boolean.Parse(jobj["success"].ToString()) == true);
        }
コード例 #3
0
        public async Task DraftVideoAdAsync()
        {
            var request = new AdCreativeCreatingRequest
            {
                ObjectStorySpec = new ObjectStorySpec
                {
                    PageId    = TestsBase.PageId,
                    VideoData = new VideoData
                    {
                        Call2Action = new Call2Action
                        {
                            Type  = Call2ActionType.LEARN_MORE,
                            Value = new Call2ActionValue
                            {
                                Link = TestsBase.Link
                            }
                        },
                        Headline = "Headline of Video Ad With default Cover",
                        Message  = Guid.NewGuid().ToString("N")
                    }
                }
            };

            var response = await AdCreativePublisher.PublishVideoAdAsync(TestsBase.TestVideoPath, request, TestsBase.AdAccountId, TestsBase.AccessToken, TestsBase.PageAccessToken, false);

            Assert.IsTrue(response.Code == ResponseCode.SUCCESS, response.ReasonPhrase ?? String.Empty);

            var jobj = JObject.Parse(response.Data);

            Assert.IsTrue((jobj["video_id"] != null && !String.IsNullOrEmpty(jobj["video_id"].ToString())) ||
                          (jobj["id"] != null && !String.IsNullOrEmpty(jobj["id"].ToString())));
        }