duanpanyang1962 2013-10-17 09:26
浏览 102
已采纳

在facebook ads api中获取图像的哈希码

I'm trying to get hash image using the Facebook Ads api. I didn't understand how to make the call. I have the image Url as string and the image itself as Byte[].

This is the example from FB documentation:

curl -F 'test.jpg=@test.jpg' -F 'access_token=_' "https://graph.facebook.com/act_368811234/adimages"

What is the test.jpg=@test.jpg means ? It's not something that I've seen before.

You can find the relevant Facebook documentation URL at: https://developers.facebook.com/docs/reference/ads-api/adimage/

Thank you

  • 写回答

1条回答 默认 最新

  • douwen7516 2013-10-18 03:10
    关注

    The following part of the curl request means post a parameter named test.jpg which references a local file path within the current directory called test.jpg.

    test.jpg=@test.jpg
    

    If you're using c#, you may want to take a look at the open source library available from facebooksdk.net (note, it's not produced by Facebook): http://facebooksdk.net/docs/making-synchronous-requests/

    Using this, it will likely be a couple of lines of code:

    var fb = new FacebookClient("access_token");
    string attachementPath = @"C:\\image.jpg";
    dynamic result = fb.Post("act_YOURACCOUNTID/adimages",
        new
        {
            file = new FacebookMediaObject
            {
                ContentType = "image/jpeg",
                FileName = Path.GetFileName(attachementPath)
            }.SetValue(File.ReadAllBytes(attachementPath))
        }
    );
    

    As you also tagged PHP, you can use the Facebook SDK which is produced by Facebook with the following code: https://github.com/facebook/facebook-php-sdk/

    $facebook = new Facebook(array(                                                                                       
      'appId'  => 'YOUR_APPID',                                                                                      
      'secret' => 'YOUR_APPSECRET',                                                                     
    ));                                                                                                                   
    $facebook->setAccessToken("YOUR_ACCESS_TOKEN");       
    $facebook->setFileUploadSupport(true);                                                                                
    $file='./test.jpg';                                                                                                   
    $args = array(                                                                                                        
         basename($file) => '@' . realpath($file),                                                                           
    );                                                                                                                    
    $response = $facebook->api('/act_YOURACTID/adimages','post',$args);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 pnpm 下载element-plus
  • ¥15 解决编写PyDracula时遇到的问题
  • ¥15 有没有人能解决下这个问题吗,本人不会编程
  • ¥15 plotBAPC画图出错
  • ¥30 关于#opencv#的问题:使用大疆无人机拍摄水稻田间图像,拼接成tif图片,用什么方法可以识别并框选出水稻作物行
  • ¥15 Python卡尔曼滤波融合
  • ¥20 iOS绕地区网络检测
  • ¥15 python验证码滑块图像识别
  • ¥15 根据背景及设计要求撰写设计报告
  • ¥20 能提供一下思路或者代码吗