When we post a feed on Facebook using Graph API, a parameter is passed called "Action" in which we need to pass an array of actions which contains name of action and link.
$feed=array(
'message' => "Trial fb post",
'name' => "trial",
'caption' => "Trial caption",
'actions' => array(
array(
'name' => 'Give it a try',
'link' => 'http://www.blinkpot.com/'
)
)
);
I saw some posts having like this page option by which users can like the respective page.
How can I attach that action with my post.
Related
Using the Graph API Explorer (https://developers.facebook.com/tools/explorer) how do you specify any of the parameters that are an object rather than just a string value when you click "add a field"? Things like arrays of objects such as actions field of the post (https://developers.facebook.com/docs/reference/api/post/)
it is a json object.
for example from this answer
$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);
your actions field in Graph API Explorer is
[{"name":"Get Search","link":"http:\/\/www.google.com"}]
Using PHP, can I post content to a Facebook page when I add something to my website? In this instance I'm creating a news post on our website but want to know if Facebook is capable of receiving the same content to display on our page?
You can use the Facebook php API to post on the Facebook page
$attachment = array(
'message' => '',
'name' => '',
'link' => '',
'description' => '',
'picture' => "",
'actions' => array( array(
'name' => 'Get Search',
'link' => 'http://www.google.com'
))
);
$pageid = '';
$facebook->api('/'.$pageid .'/feed?access_token='.$facebook->getAccessToken(),'post',$attachment);
There are a lot of questions on SO about this, but not exactly what I am looking for.
In my case, users can log in through Facebook/Twitter/other. And they can upload an image.
Once they upload an image, two things will happen. The FB user's status is updated with an attachment to the link. And on the FB App's wall, a status update is also posted but by the application itself and not by the user. I am having trouble with this last part. So the user does not have to be logged in through Facebook for this latter to occur.
My code:
$facebook = new Facebook($config);
$attachment = array(
'message' => 'A user just posted a new item',
'name' => $tag,
'caption' => $desc,
'link' => WEBURL,
'description' => '',
'picture' => $img,
'actions' => array(array('name' => 'Go to item',
'link' => WEBURL))
);
$facebook->api('/'.PAGEID.'/feed', 'POST', $attachment);
An application's wall behaves exactly like a page's wall or a user's wall. Lookup the documentation for those.
How do I set the height of the swf file posted to facebook feed using the PHP API.
Here is my code. It is working fine but I cant find a parameter to set the height.It height is automatically set to 259px. I tried the extended_height parameter also but no luck. Do I have to use the REST API?
$options = array(
'access_token' => $facebook->getAccessToken(),
'link' => 'http://www.example.com/',
'name' => 'Test App',
'caption' => "Created using my test app",
'picture' => $apppath.'Icon.jpg',
'source' => $apppath.'main.swf',
'description' => "Description field",
'actions' => array( 'name' => 'Click me', 'link' => 'http://www.google.com' )
);
$wallPost = $facebook->api('/'.$friendid.'/feed', 'post', $options);
Anybody got a solution ?
Have you checked this ? https://developers.facebook.com/docs/guides/attachments/
it shows how attachments are made. Plus if you want you can even use open graph tags in your page to show the media once your page is shared via FB
I'm using the old Rest API (and old Javascript SDK) to develop an iframe application inside facebook.
However I would like to have the wall posts (calling stream.Publish) to include new lines and having people's names with links to their profiles. However every time I include html content, FB strips it.. but I know it can be done, because some apps do it, for example:
http://img.skitch.com/20100702-jhqradpi3td4d53sdb3qin92sb.png
Cheers,
Ze
You cannot have arbitrary HTML in a wall post. If it looks like HTML, Facebook will strip it. The only other alteration Facebook will do I believe is convert text that looks like links into links (so if you have http://www.google.com somewhere in the message, Facebook will automatically turn it into a link).
However Facebook does provide basic facilities for including basic things like a picture, caption, description, link, etc through stream.publish by passing in additional parameters. This is an example for including a few of these things from Facebook's documentation (http://wiki.developers.facebook.com/index.php/Stream.publish):
$message = 'Check out this cute pic.';
$attachment = array(
'name' => 'i\'m bursting with joy',
'href' => 'http://icanhascheezburger.com/2009/04/22/funny-pictures-bursting-with-joy/',
'caption' => '{*actor*} rated the lolcat 5 stars',
'description' => 'a funny looking cat',
'properties' => array('category' => array(
'text' => 'humor',
'href' => 'http://www.icanhascheezburger.com/category/humor'),
'ratings' => '5 stars'),
'media' => array(array('type' => 'image',
'src' => 'http://icanhascheezburger.files.wordpress.com/2009/03/funny-pictures-your-cat-is-bursting-with-joy1.jpg',
'href' => 'http://icanhascheezburger.com/2009/04/22/funny-pictures-bursting-with-joy/')),
'latitude' => '41.4', //Let's add some custom metadata in the form of key/value pairs
'longitude' => '2.19');
$action_links = array(
array('text' => 'Recaption this',
'href' => 'http://mine.icanhascheezburger.com/default.aspx?tiid=1192742&recap=1#step2'));
$attachment = json_encode($attachment);
$action_links = json_encode($action_links);
$facebook->api_client->stream_publish($message, $attachment, $action_links);
Check this out for more info on what attachments you can include.