コード例 #1
0
        public ActionResult ReadAds(Parameters parameters)
        {
            if (!IsLogged())
            {
                return(Unauthorized());
            }

            var urlParameters = new Dictionary <string, string> {
                { "q", parameters.ProductName }
            };

            var baseUrl = string.IsNullOrEmpty(parameters.SearchRegion)
                ? "https://olx.com.br/brasil"
                : $"https://{parameters.SearchRegion}.olx.com.br";


            var webCrawler = new WebCrawler(baseUrl, urlParameters);

            var ads = webCrawler.Read();

            foreach (var ad in ads)
            {
                _adService.Create(ad);
            }

            return(NoContent());
        }
コード例 #2
0
        public void CreateAds()
        {
            //Act
            //IFacebookClient client = new FacebookClient("2.9", "1057652130914324", "9ffc28c2a12d447cb5132995656ac92c", "client_credentials");
            IFacebookClient client = new FacebookClient("2.9", "EAANOERzv1jEBAMcBC4tDSqpbb1AWfYZAj3BZCoifcMgm3yOADpVWmonpa8drpMyiP6JPf3UAdYbpM4j6NmBIhzIBlF2NyAid1ecKvWWTNXvM8cNWCZBleZCZA2EONXXczk4nFdKtz99NB52POJARZAc2ArQtYEIi8ZD");

            //Service
            IAdService service = new AdService(client);

            //Create
            Ad ad = new Ad();

            ad.Name    = "Test AD";
            ad.Status  = JAM.Facebook.Models.Enums.Status.PAUSED;
            ad.AdSetId = 23842605921750113; //Post Engag

            ad.Creative = new AdCreative()
            {
                CreativeId = "23842605023090113" //Este creative ya existia y se habia creado anteriormente
                                                 // CreativeId = "23842605023090113" //Se creo este creative pero hay que averiguar que clase de post aplica para LINK_CLICK
            };
            var response = service.Create("10155310538728783", ad);

            Assert.IsNotNull(response); //Ads Create for APi: 23842605030960113
        }
コード例 #3
0
        private void Update(AdInfo model)
        {
            var errors = false;

            if (string.IsNullOrEmpty(model.Name))
            {
                ModelState.AddModelError("Name", "广告物料不能为空");
                errors = true;
            }
            if (string.IsNullOrEmpty(model.ClickUrl))
            {
                ModelState.AddModelError("ClickUrl", "点击链接不能为空");
                errors = true;
            }
            if (ModelState.IsValid && !errors)
            {
                AdService.Create(model);
                ViewBag.Msg = "保存成功!";
            }
        }