実際の広告を作成するときに後で画像ハッシュを使用するために、PowershellのFacebook広告管理APIに画像をアップロードしようとしています。Facebook広告管理APIを使用した画像のアップロード
$fileName = "adimage.jpg"
$fileContent = get-content $fileName
$fileContentBytes = [System.Text.Encoding]::UTF8.GetBytes($fileContent)
$fileContentEncoded = [System.Convert]::ToBase64String($fileContentBytes)
$parameters = @{
access_token = "abc"
bytes = $fileContentEncoded
}
$result = Invoke-WebRequest -Uri "https://graph.facebook.com/v2.7/act_12345678/adimages" -Method Post -ContentType "image/jpeg" -body $parameters
私は常に取得:adimagesエンドポイントのAPIページがある
{"error":{"message":"Invalid parameter","type":"OAuthException","code":100,"error_subcode":1487242,
"is_transient":false,"error_user_title":"Image Resize Failed",
"error_user_msg":"Image Resize Failed:Could not get image size","fbtrace_id":"Bl\/fu39rM2W"}}
: https://developers.facebook.com/docs/marketing-api/reference/ad-image
私たちは、基本的に私が持っている
curl -F "[email protected]" -F "access_token=abc" https://graph.facebook.com/v2.7/act_12345678/adimages
の同等を探していますまた試しました:
「バイト=(取得コンテンツをadimage.jpg -raw)」- フォームフィールド
- この結果は(とも他のいくつかのバリエーションの)私はエラーと200応答が、空コンテンツフィールドを取得していないということで、何のファイルがどちらか
イメージがある:資産管理GUI経由 https://www.dropbox.com/s/hkx236uiiy1p54e/adimage.jpg?dl=0 と https://www.dropbox.com/s/gf9on4w8ijbfwl8/adimage.png?dl=0
アップロードが働きました。
アイデア?
サンドロ
更新:それは確かにMac上カールと魅力のように動作しませんでした。そのため、画像そのものに関することはほとんどありません。
はそれが仕事を得ることができませんでした。非常に粗い回避策を使用しています。これはcygwinインストールのCURLを使用しています。あなたが貢献するものがあれば、まだ回答を投稿してください。ありがとう:-) – Sandro