尝试在Facebook ADS Api上使用带有Visual Basic的FacebookMediaObject添加图像 [英] Trying to add an Image using FacebookMediaObject with Visual Basic on the Facebook ADS Api
问题描述
在使用Visual Basic中的FacebookMediaObject添加广告组以使用Facebook ADS Api创建新添加项时,我一直遇到问题.
I've been having a problem adding an AdGroup using the FacebookMediaObject in Visual Basic to create a new add using the Facebook ADS Api.
我知道访问它的人并不多,但我希望这里的人能对此有所了解.
I understand not many people have access to it, but I hope someone here can shedd a light on it.
Dim objAuthorizer As Authorizer = New Authorizer
Dim objFB As FacebookClient = New FacebookClient(objAuthorizer.Session.AccessToken)
Dim objParametersTargeting As Object = New ExpandoObject()
Dim arrCountries() As String
ReDim arrCountries(0)
arrCountries(0) = "NL"
objParametersTargeting.countries = arrCountries
Dim objCreative As Object = New ExpandoObject()
objCreative.title = "Test Adgroup title"
objCreative.body = "Test Adgroup body"
objCreative.link_url = "www.test.com"
objCreative.image_file = "testcups.jpg"
Dim strFilename As String = "C:\Upload\testcups.jpg"
Dim objAdgroupParameters() As Object
ReDim objAdgroupParameters(0)
objAdgroupParameters(0) = New ExpandoObject()
objAdgroupParameters(0).campaign_id = "123456789"
objAdgroupParameters(0).name = "Test adgroup"
objAdgroupParameters(0).bid_type = 1
objAdgroupParameters(0).max_bid = 50
objAdgroupParameters(0).targeting = objParametersTargeting
objAdgroupParameters(0).creative = objCreative
Dim fbUplImage = New Facebook.FacebookMediaObject
fbUplImage.FileName = "testcups.jpg"
fbUplImage.ContentType = "image/png"
Dim objBytes As Byte() = System.IO.File.ReadAllBytes(strFilename)
fbUplImage.SetValue(objBytes)
Dim objParameters As Object = New ExpandoObject()
objParameters.method = "ads.createAdGroups"
objParameters.account_id = "123456789"
objParameters.adgroup_specs = objAdgroupParameters
objParameters.image = fbUplImage
Dim objResult As Object = objFB.Post(objParameters)
当然,帐户ID和广告系列ID必须是有效ID(在我的本地来源中是有效ID),并且文件必须存在于硬盘驱动器上(也位于我的本地驱动器上).
Of course the Account ID and the Campaign ID have to be valid ID's (which are valid ID's in my local source) and the file has to exist on your harddrive (which also is there on my local drive).
我不断获得以下结果:
{"updated_adgroups":[],"failed_adgroups":[{"spec_number":"0","errors":["Filesystem entity `/testcups.jpg' does not exist."]}]}
外面有人有线索吗?
预先感谢, 巴斯
一些额外的信息: 我发现(使用HTTP嗅探器)Facebook C#SDK没有发出多部分发布"请求
Some extra info: I found out (with a HTTP sniffer) that the Facebook C# SDK isn't making a Multipart Post requestout o
推荐答案
您是否尝试过将"fbUplImage.ContentType =" image/png切换为image/jpg?
Have you tried switching "fbUplImage.ContentType = "image/png" to image/jpg?
这篇关于尝试在Facebook ADS Api上使用带有Visual Basic的FacebookMediaObject添加图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!