how to post on a facebook event wall? - php

Im new at facebook app development and I am trying to make an automatic post on an event wall. I have read that include the id to post on a specific wall. I have tried that but it doesn't work.
I thought that maybe it would work with "to" (a specific targeted wall), but I don't know it's syntax...
can anyone help? or at least give an example of a post syntax with a "to" property included... plssss...

$attachment = array(
'message' => 'this is my message',
'name' => 'This is my demo Facebook application!',
'caption' => "Caption of the Post",
'link' => 'http://mylink.com',
'description' => 'this is a description',
'picture' => 'http://mysite.com/pic.gif',
'actions' => array(array('name' => 'Get Search',
'link' => 'http://www.google.com'))
);
$uid = ""; //friend id OR "me"
$result = $facebook->api('/'.$uid.'/feed/','post',$attachment);
http://developers.facebook.com/docs/reference/api/post/
NOTE: you should have the user publish_stream extended permission and you should have the SDK Lib loaded.

$attachment = array(
'message' => 'this is my message'
);
$eid = ""; //event id
$result = $facebook->api('/'.$eid.'/feed/','post',$attachment);
http://developers.facebook.com/docs/reference/api/event/ <-- event object documentation
or
https://api.facebook.com/method/stream.publish?message=<your_message>&target_id=<event_id>&access_token=<your_token>

Related

How to auto publish on application's wall using PHP

I have requirement that whatever I store on server database (like adding new question), it should auto publish to application's wall so that users who likes application can see regular updates.
How is it possible using PHP?
Any answer would be appreciated.
Thanks in advance.
You have to set a listener that will read the new changes on db or from the interface where u are setting the data for the database call the fb api and post it inmediatly... in that case would be something like this.
$autpost = array('message' => ' message',
'name' => 'This is my demo',
'caption' => "Caption ",
'link' => 'http://facebook.com',
'description' => 'description',
'picture' => 'http://somesite.picture.jpg',
'actions' => array(array('name' => 'Get Search',
'link' => 'http://www.google.com'))
);
$result = $facebook->api('/fanpage id/feed/', 'post', $wall_post);

Facebook php sdk - post to a wall with prompt

T'm writing a Facebook canvas app, and I'm trying to post to the user's wall. this the code I'm using:
if ($user) {
$attachment = array('message' => 'This is message',
'name' => 'Name of the message',
'caption' => 'Caption of link',
'link' => 'http://www.example.com/about',
'description' => 'Great site!',
'picture' => 'http://lorempixum.com/100/100/',
'actions' => array(array('name' => 'Do Something!',
'link' => 'http://www.example.com'))
);
$result = $facebook->api('/me/feed/',
'post',
$attachment);
}
So I tested with 2 facebook accounts, and it posts to the wall but without the facebook dialog i'm always seeing. I would like the user to be warned that I'm gonna post on the wall, and allow him to cancel it.
How do I do that?
You need to use the JavaScript SDK, essentially the dialogs bit: http://developers.facebook.com/docs/reference/dialogs/feed/

facebook wall post no image

I am adding functionality to post to a visitors Facebook wall.
I am using the following code:
$path_to_image = "http://projects.kleelof.com/boot_designer/image_interchange.php?c=" . $file_id;
$attachment = array('message' => 'this is my message',
'name' => 'The name of your company',
'caption' => "Caption of the Post",
'link' => $path_to_image,
'picture' => $path_to_image,
'description' => 'this is a description',
'access_token' => $facebook->getAccessToken()
);
//echo($path_to_image);
$result = $facebook->api('/me/feed/','post',$attachment);
The post appears on my wall, but not the image.
You can see the full process and post it makes by trying the app at: http://projects.kleelof.com/boot_designer - Then select either one of the 2 links.
take care,
lee
I think the path to the image needs to be and actual file system path, and the image will be read and uploaded along with the request for FB to process. Also, it needs to start with a # to actually upload it.

Publish on user's wall using application's name

I'm using Facebook GRAPH API to publish on user's wall.
It works fine, but I'm encountering a little problem:
My publication appears on the user's wall with the user's name, as if he published himself
I want to publish on his wall but with my application's name
How can I do this ?
First you need user post stream permission. After you get user credential, then you can try send $_POST with structure like these
$stream_data = array(
'access_token' => $user_access_token,
'caption' => 'From Your App',
'description' => 'Your App description',
'link' => 'http://yourapp.com',
'picture' => 'http://yourapp.com/assets/img/someicon.png',
'name' => $user_sess_name.' just started uses Your App name.',
);
to https://graph.facebook.com/1234/feed (1234 is a user id) to create a feed stream.
There is no way to post on a user's wall and have it attributed to the app itself, only users may write on each other's walls, there's no way for an app or Page to write on a Profile's wall.
toopay's answer is a good example of posting to a user's wall from an app, but that post would be attributed to the user whose access token you use
I don't think so you can post on user's wall with the app name, You can use the below code to post on user wall and it will say on the Bottom VIA app name
$fb = new Facebook(array(
'appId' => '2420527xxxxxxx',
'secret' => 'a6b14d618xxxxxxxxxxxxxxxxxxx'
));
try {
$attachment = array(
'message' => '',
'access_token' => $fb->getAccessToken(),
'name' => 'Attachment Name',
'caption' => 'Attachment Caption',
'link' => 'http://www.xxxxxxx.com/app/',
'description' => 'Description .....',
'picture' => 'http://www.xxxxxxx.com/logo.xxx',
'actions' => array(array('name' => 'Action Text','link' =>'http://www.xxx.com/app/'))
);
$result = $fb->api('/'.$fb->getAppId().'/feed/', 'post', $attachment);
echo $result;
}catch (FacebookApiException $e) {
echo $e->getMessage()."\n";
}
Try it..!!!

Posting on friend's wall

How do I post to friend's wall using PHP Graph API? I got some javascript solutions. But I need PHP ones. Thank you.
Check the documentation here http://developers.facebook.com/docs/reference/api/post/.
Try $facebook->api('/Friend_ID/feed','post',array('message'=$message));. Refer to the documention for more parameters.
it requires few things
Create a Facebook Application: FB Documentation
Request extended permissions to access a user's photos and their friend's photos Facebook Auth / Permissions
FQL + JSDK to request the data JSDK Doc
$attachment = array('message' => 'this is my message',
'name' => 'This is my demo Facebook application!',
'caption' => "Caption of the Post",
'link' => 'http://mylink.com',
'description' => 'this is a description',
'picture' => 'http://mysite.com/pic.gif',
'actions' => array(array('name' => 'Get Search',
'link' => 'http://www.google.com'))
);
$result = $facebook->api('/me/feed/',
'post',
$attachment);
good luck

Categories