Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
177 views
in Technique[技术] by (71.8m points)

php - Posting Picture on Event Page

i am having a Problem posting a Picture in the Wall of an Event on Facebook. It is Posting

My current Code is:

$post_array = array(
    "access_token" => $facebook->getAccessToken(),
    'source' => "@" . realpath("image.png"),
    'message' => 'Some Message'
);
$post_id = $facebook->api("/".$event_id['id']."/feed", "POST", $post_array);

Everything is working fine, except for the Image: It won't be displayed.

Any Help out there?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

If for Events, Try:


//Setup the Facebook object for file upload
$facebook = new Facebook(array(
  'appId'  => 'your_app_id_here',
  'secret' => 'your_secret_here',
  'cookie' => true,
  'fileUpload' => true
));

Then:


$file = "image.png";
//The event information array (timestamps are "Facebook time"...)
$event_info = array(
    "access_token' => 'your access token",    
    "name" => "Event Title",    
    "start_time" => 1290790800,
    "end_time" => 1290799800,
    "location" => "Your Location",
    "description" => "Event Description"
);

$event_info[basename($file)] = '@' . realpath($file);

$result = $facebook->api('me/events','post',$event_info);

Hope it helps


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...