开发者

How to add profile image to event using the new php graph api

Using the php graph api I want to add picture to an event. So I m looking for some examples for the new graph api !


I'm sorry if the question is a bit unclear. Creating an event facebook use standard pictures of 31

calendar icon of facebook

How to add profile image to event using the new php graph api

http://i.stack.imgur.com/w7tMp.png in monocolor and color

I ( and many other person ) want to replace this picture using php as you can do it via the facebook page. All descriptions in the internet fail. I use the following code

$name= $parameter['betreff'];  
$beschreibung=$parameter['thema'];
start_time = $parameter['anfangsdatum'] . " " . $parameter['an开发者_如何转开发fangszeit'];
$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);

The event is created on the fanpage but without any picture ! Why ?


Your question is a bit unclear, but assuming I've understood you correctly, you simply want a users profile picture? That can be found here: http://graph.facebook.com/username/picture

So mine would be at http://graph.facebook.com/filip.soderholm/picture

You may also use the userId instead of the username if you have that.


You can get help from this address: 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);
      }   
    }   
  }
} 
?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜