Using the Facebook PHP SDK to post from Group - php

I'd like to use the Facebook PHP SDK to post on a user's wall FROM a group (i.e. not as a Status Update, from the user via an external app, but from a group via an external app). I'm having a difficult time finding docs on the topic, and would like a code example as well as any information regarding any restrictions (e.g. can a group post on one's wall if the user does not belong to the group).
I've tried using the 'from' parameter, like this:
$attachment = array(
'access_token' => $access_token,
'message' => "Message from the group",
'name' => "Name of the Post",
'from' => array(
'name' => "Sender's Name",
'id' => "#############"
),
'link' => "http://myurl.com/",
'description' => "Description of the Posting",
'picture'=>"http://myurl.com/mylogo.png",
);
$ret_code=$facebook->api('/'.$fb_id.'/feed', 'POST', $attachment);

While posting as a "Page" is totally possible by getting a page access_token, I've never seen anything similar for Facebook groups. So I would assume that this is NOT possible.

Related

Empty story clicks statistics in Facebook application insights

Posting stories via php facebook application using such construction :
$facebook->api('/'.$wall_id.'/feed',
'post',
array(
'access_token' => $access_token,
'message' => $message,
'picture' => $picture,
'caption' => $caption,
'link' => $link
)
);
There are "702 Stories Published" in app insights ( Apps->My application->Insights->Stream Publish ). But there are no Story Impressions or Story Clicks at all. (702 - 0 - 0)
Is it a bug, or do I need to pass some additional parameters to FB api to track these clicks?
How much time has passed since the stories have been first posted? Facebook Insights requires at least three days to update its data.
Let's wait, and we'll see if this is a bug. I don't know about any special parameter to enable tracking: it should be available without any configuration.

facebook PHP SDK posting as activity, not post

I hope you will be able to help me.
I'm developing an app, and I'm willing to post an activity (that appears on user timeline in recent activity) everytime the user use my application.
Although, for the moment, I have this code below, and it only posts a normal link :
if($can_post){
$facebook->api('/'.$uid.'/feed', 'post', array(
'message' => '',
'name' => 'Name',
'caption' => 'Caption',
'description' => 'SDesc',
'picture' => 'picture url',
'link' => 'link',
'actions' => array(array('name' => 'catch phrase',
'link' => 'http://link'))
));
Check out this guide on posting "stories" to the user's timeline using the Open Graph API, so maybe it's this functionality that you need. The example they give is just a like, but it can be easily modified.
Be aware that Facebook will have to approve you app again if you want to use stories (see end of page on link above).
It's also worth noting that Facebook have also defined a wide range of predefined "Actions" to help in the process, so it's a good idea to check to see if your app falls into one of these categories.

How to post on group wall?

First, what I have:
I have an FB app which is able to get a user's access_token and post on user's wall using FB API in PHP.
Can anyone please help me to 1) post on my all groups wall using a batch request (or any other technique) and 2) how to get my all groups id?
If I use my app to post on my all groups (100+) wall, is it ok with FB?
Does FB treat this as spam ?
Thanks
i have created a facebook application 1 month back, called WooTube
To promote my application free,i joined around of 100 Groups to promote my fb video app in various of interest base like "KPOP,SNSD,SUPER JUNIOR,Just For Laught and etc" with my application build in features "Post To My Group".It is writen using fb.api
https://fbcdn-sphotos-h-a.akamaihd.net/hphotos-ak-ash4/383568_191076937694203_922285357_n.jpg
Unfortunately this is spam...i was blocked from facebook for 2 days due to spamming.The reason is i shared the same link for around 30-40 time in less then 5-10 minutes.
what i would like to suggest is:
Do not share the same link for more then 20 times per day (to be safe)
Do not post too frequence, each post should have a space of 10 second.
Don't used your own account for spamming (you know what i talking about :) )
You can use Facebook batch API to post to multiple wall (groups, pages or friends wall).
The basic method to do it is shown below. The IDs can be User IDs, group IDs or Page IDs.
You can read more about it at: http://25labs.com/tutorial-post-to-multiple-facebook-wall-or-timeline-in-one-go-using-graph-api-batch-request/
$batchPost[] = array(
'method' => 'POST',
'relative_url' => "/{ID1}/feed",
'body' => http_build_query($body) );
$batchPost[] = array(
'method' => 'POST',
'relative_url' => "/{ID2}/feed",
'body' => http_build_query($body) );
$batchPost[] = array(
'method' => 'POST',
'relative_url' => "/{ID3}/feed",
'body' => http_build_query($body) );
$multiPostResponse = $facebook->api('?batch='.urlencode(json_encode($batchPost)), 'POST');

how to add share action to the post in facebook?

i'm using this code to post to my application wall
$attachment = array('message' => 'xxxxxxxxxxxxxxxx...',
'name' => 'xxxxxxxxxxxxxxxxxxx',
'caption' => 'xxxxxxxxxxxxxxxxxx',
'link' => 'xxxxxxxxxxxxxxxxxx',
'description' => 'xxxxxxxxxxxxxxxxxx',
'picture' => 'xxxxxxxxxxxxxxxxxx',
'actions' => array(array('name' => 'Download!',
'link' => 'xxxxxxxxxxxxxxxxxx'))
);
$result = $facebook->api('/2222222222222/feed/','post',$attachment);
when i post to my application wall manually the post is appearing on the application users wall with the share action
but when i use the above code it only appear on the app wall with like and comment actions only.
why?
and how to add the share action to the actions array?
i didn't find any answer online, but i just found the solution to my problem by chance
i removed the action parameter from the attachment.
but if there is a link parameter in the attachment the share action won't appear so you will have to give up the link parameter.
the proper names for the action link is:
array( array('text' => 'Download!', 'href' => 'xxxxxxxxxxxxxxx'));
Keep in mind that you can't use action links in the graph api (yet). so this functionality is limited to the REST api.
Let me know if this helps
http://facebookanswers.co.uk/?p=270
This article explains it. The key is this:
'actions' => array('name'=>'Sweet FA','link'=>'http://www.facebookanswers.co.uk'),
This is fine for adding one action. However, I'm not sure how to add two.
Hi the solution is here
instead of
$result = $facebook->api('/2222222222222/feed/','post',$attachment);
use
$result = $facebook->api('/2222222222222/links/','post',$attachment);
i'm still facing one little problem with the picture not showing after this change, if i come to a solution to it I'll come back here and post it.

Facebook Graph API: How to add vote links to a wall post?

I am building a Facebook app with voting included. With it I want to send a message to the user's wall including some text and two or more links.
I also want to control the link text so that I can get links like "Yes" and "No".
The first thing I tried was posting regular -tags, but (no surprise) that didn't work. I have seen other apps do this though. Are there any special tags that allow links?
Thank you.
I'll assume that you're using the Graph API and already have publish a post working.
I think the properties property might be what you are looking for (it is left out of the new API reference but is described here). This allows links although they might not be formatted quite how you want. Example:
$data = array (
'name' => ...,
'link' => ...,
'properties' => array (
'Yes' => array (
'text' => 'Vote',
'href' => 'http://www.example.com?vote=yes'
),
'No' => array (
'text' => 'Vote',
'href' => 'http://www.example.com?vote=no'
)
),
); //And whatever other properties you want
$facebook->api('/uid/feed', 'POST', $data);
The properties will appear after beneath description in the post and come out like the following:
Yes: Vote

Categories