我有麻烦上载图片到facebook广告api。图片位于服务器上,我正试图使用curl让它工作。我的代码如下所示,但它不起作用。知道为什么吗?由于
$targeting=array('countries'=>array('US'),'gender'=>array('1'));
$creative=array('title'=>'test me','body'=>'this is a test','link_url'=>'http://www.myurl.com','image_file'=>'test.jpg');
$adgroup_spec=array('campaign_id'=>$campaignid,
'name'=>'test',
'bid_type'=>1,
'max_bid'=>10,
'targeting'=>$targeting,
'creative'=>$creative
);
$adgroup_spec=urlencode(json_encode($adgroup_spec));
$path_to_image='@.test.jpg';
$url="https://api.facebook.com/method/ads.createAdgroups?account_id=$MYACCOUNTID&adgroup_specs=$adgroup_spec&access_token=$accesstoken&$image_file=$path_to_image&format=json";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$output = curl_exec($ch);
curl_close($ch);
图像从未创建,我得到错误->图像调整失败:getimagesize函数返回false
也许您必须指定image_file参数
并指定"image_file_name"
例子:
-F "image_file=name.jpg" -F "name.jpg=@./upload.jpg"
示例代码:
curl -F "type=1" -F "name=name_sample" -F "title=title_sample" -F "body=body_sample" -F "link_url=http://www.sample.co.jp/" -F "image_file=name.jpg" -F "name.jpg=@./upload.jpg" "https://graph.facebook.com/act_id/adcreatives?&access_token=______"