使用php graph api我想将图片添加到事件中。所以我正在寻找新的图形api的一些例子!
如果问题有点不清楚,我很抱歉。创建活动facebook使用31的标准图片
facebook的日历图标
单色和彩色http://i.stack.imgur.com/w7tMp.png
我(以及许多其他人)想要使用php替换此图片,因为您可以通过Facebook页面进行操作。 互联网上的所有描述都失败了。 我使用以下代码
$name= $parameter['betreff'];
$beschreibung=$parameter['thema'];
start_time = $parameter['anfangsdatum'] . " " . $parameter['anfangszeit'];
$ort="" . $parameter['ort'];
$picture='http://www.tvwehen.de/facebook/facebook_plan_event/news.png';
$privacy="CLOSED";
$event_param = array(
'access_token' => $access_token,
'page_id' =>$fanPageId,
'name' => $name,
'start_time' => $start_time,
'description' => $beschreibung,
'location' => $ort,
'pic_big' => $picture,
'pic_small' => $picture,
'logo.png' => $picture,
'privacy' => $privacy
);
$event_id = $facebook->api($fanPageId . "/events", "POST", $event_param);
该活动是在粉丝页面上创建的,但没有任何图片!为什么?
答案 0 :(得分:0)
您的问题有点不清楚,但假设我理解正确,您只需要用户个人资料图片?这可以在这里找到: http://graph.facebook.com/username/picture
因此我将在http://graph.facebook.com/filip.soderholm/picture
如果您有用户名,也可以使用userId代替用户名。
答案 1 :(得分:0)
您可以从以下地址获得帮助:https://gist.github.com/1178154
<?php
/**
* Implementation of hook_nodeapi
*/
function hps_the_hook_nodeapi (&$node, $op, $a3 = NULL, $a4 = NULL) {
if ($node->type == 'event') {
if ($op == 'insert') {
dpm($node);
//require_once(drupal_get_path('module', 'hps_the_hook') . '/lib/facebook-php-sdk/src/facebook.php');
$facebook = new Facebook(array(
'appId' => '193560340711521',
'secret' => 'secret',
'fileUpload' => true,
));
$page_id = "161330440592966";
$location = $node->field_location[0]['value'];
$from_date = $node->field_date[0]['value'];
$to_date = $node->field_date[0]['value2'];
$image_path = $node->field_image[0]['filepath'];
$event_param = array(
"access_token" => 'access_token',
"name" => $node->title,
"start_time" => strtotime($from_date),
"end_time" => strtotime($to_date),
"location" => $location,
"page_id" => $page_id,
"picture" => "@".realpath($image_path),
"source" => "@".realpath($image_path),
);
$facebook->setFileUploadSupport(true);
try {
dpm($event_param);
$event_id = $facebook->api("/161330440592966/events", "POST", $event_param);
dpm($event_id);
}
catch (Exception $ex) {
dpm($ex);
}
}
}
}
?>