Php 来自外部URL的Facebook事件档案图片

Php 来自外部URL的Facebook事件档案图片,php,facebook,events,facebook-events,Php,Facebook,Events,Facebook Events,我正在尝试用PHP创建Facebook事件。我遇到的最后一个问题是个人资料图片。 我的问题是: 我可以使用事件配置文件图片的外部图片url吗??? 如果是,那么如何发送?您将无法实际使用该URL作为配置文件图片发送,但如果您首先将其下载到服务器,则可以使用它。只要将file\u get\u contents()和file\u put\u contents()简单地结合起来,就可以在图像上进行复制 $externalImage = 'http://lorempixel.com/400/200/'


我正在尝试用PHP创建Facebook事件。我遇到的最后一个问题是个人资料图片。

我的问题是:
我可以使用事件配置文件图片的外部图片url吗???

如果是,那么如何发送?

您将无法实际使用该URL作为配置文件图片发送,但如果您首先将其下载到服务器,则可以使用它。只要将
file\u get\u contents()
file\u put\u contents()
简单地结合起来,就可以在图像上进行复制

$externalImage = 'http://lorempixel.com/400/200/';
$tempImagePath = 'tmp/temp_image_path.jpg';
// save remote file to the server to $tempImagePath
file_put_contents( $tempImagePath, file_get_contents( $externalImage ));
// upload the image to the event
$facebook->api("/EVENT_ID/picture", "POST", 
  array('source' => '@'. realpath($tempImagePath) )
);
// remove temp image
unlink($tempImagePath);

因此,Lix中的代码仅从第二部分开始工作。但这里有一个完整的工作代码

$externalImage = 'External link to image';
$tempImagePath = 'Local link to save image';
$user = 123456789; // USER ID
// save image
file_put_contents( $tempImagePath, file_get_contents( $externalImage ));
// Create data for new event
$data = array(
  'name'         => 'Event title',
  'description'  => 'Event description',
  'owner'        => $user, // user as owner of this event
  'location'     => 'Location',
  'start_time'   => '2013-05-08T11:00:00-0700',
  'end_time'     => '2013-05-09T19:00:00-0700',
  '@file.jpg'    => '@'.realpath($tempImagePath),
  'privacy_type' => 'OPEN'
);
// Create event
$eventID = $facebook->api('/'.$account.'/events', 'post', $data); 

如果您有问题,请写信给我。

这很奇怪,因为在事件创建中,您可以使用参数“picture-事件图片的URL”哦。。。很抱歉我以为你的意思是你想在外部主持图像…它不起作用。错误:$facebook->api CALL中的数组到字符串转换提供的参数之一是一个数组,它应该是字符串。请查看您指定的参数。。。