【问题标题】:Getting hashcode for image in facebook ads api在 facebook ads api 中获取图像的哈希码
【发布时间】:2013-10-18 11:10:51
【问题描述】:

我正在尝试使用 Facebook Ads api 获取哈希图像。 我不明白如何拨打电话。 我有 image Url as stringimage 本身作为 Byte[]

这是来自 FB 文档的示例:

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

test.jpg=@test.jpg 是什么意思?这不是我以前见过的东西。

您可以在以下位置找到相关的 Facebook 文档 URL:https://developers.facebook.com/docs/reference/ads-api/adimage/

谢谢

【问题讨论】:

    标签: c# php facebook facebook-graph-api facebook-ads-api


    【解决方案1】:

    curl 请求的以下部分表示发布一个名为 test.jpg 的参数,该参数引用当前目录中名为 test.jpg 的本地文件路径。

    test.jpg=@test.jpg
    

    如果您使用的是 c#,您可能需要查看 facebooksdk.net 提供的开源库(注意,它不是由 Facebook 生产的): http://facebooksdk.net/docs/making-synchronous-requests/

    使用它,可能会是几行代码:

    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))
        }
    );
    

    由于您还标记了 PHP,您可以使用 Facebook 生产的 Facebook SDK,代码如下: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);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-08-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多