I'm trying to post an event on a group wall-
try
{
$ret_obj = $facebook->api($groupId.'/feed', 'POST',
array(
'link' => 'https://www.facebook.com/events/EVENT_ID/'));
}
catch(FacebookApiException $e)
{
}
this code post successfully the event but it doesn't appear properly on the group .
it only show the name of the event,but doesnt show picture,details and more...
ps: it work properly on page wall and i have chech my group permissions
tell me what wrong,is it a facebook issue ??
Facebook might not be able to fetch the details from the link; you can manually set the other parameters-
array(
'lik' => 'https://www.facebook.com/events/EVENT_ID/',
'picture' => PICTURE_URL,
'description' => DESC,
'caption' => CAPTION ));
Related
I'm building an app for facebook. I need to post some link, standard code works correctly:
$ret_obj = $facebook->api('/me/feed', 'POST',
array(
'link' => 'Mylink',
'message' => 'Posting with the PHP SDK!',
But I need to attach the photo also. It works if photo is on the link I post, but I don't want that photo to appear on that page.
Is there any way?
Simply add a parameter, picture to while making the call-
array(
'link' => 'Mylink',
'message' => 'Posting with the PHP SDK!',
'picture' => '{image-link}'
So I'm creating posts to the facebook user's wall using Graph API
I'm referring to the 'caption' as stated here:
http://nocturnsoft.com/devblog/?p=906
when I specified the 'caption' option, the text in the caption would appear properly for profiles that uses the timeline, but for profile that use the old style, the caption would not appear...
Am I doing something wrong here or is this how it's supposed to be....If it is how it's supposed to be, how would I display text beneath the link for the Facebook post for non timeline profiles
btw: I'm using Facebook PHP SDK
In my apps the post data array looks like this and the caption (message) is present on both new and old profiles.
/* post to fb */
$post = array(
'access_token' => $fb_access_token,
'message' => 'THIS IS YOUR CAPTION HERE',
'link' => 'LINK TO YOUR SITE OR APP HERE',
'picture' => 'URL TO IMAGE HERE',
'name' => 'APP NAME HERE',
'description' => 'AWESOME DESCRIPTION ABOUT YOUR APP GOES RIGHT HERE!'
);
$res = $facebook->api('/me/feed', 'POST', $post);
Hope this helps. If so don't forget to say so! :)
I'm doing a facebook app and it was working good till yesterday. I did was let user's choose 20 of their friends and wrote a simple script to post to their wall from a loop like this:
foreach($selectedids as $selectedid) {
$invitation = new Invitations();
$invitation->circle_id = $circle->id;
$invitation->status = 0;
$invitation->follower_id = $selectedid;
if ($invitation->create()) {
$id = $invitation->id;
// Now Send the Invitations on Facebook
$facebook->api($selectedid.'/feed', 'post', array(
'picture' => '',
'message' => $name."something",
'name' => $config['app_title'],
'link' => $config['redirect_uri']."?invitation=".$id,
'caption' => '',
'description' => '',
'actions' => array(array('name' => 'Get Search',
'link' => 'http://www.google.com'))
));
}
}
Till yesterday everything was fine but when now multiple user's use this at once the script would stop after a post to about 7-8 friend and give an error that it couldn't complete task. Is there a better way to post to multiple peoples in facebook? What shall I do, would make this perform better? Any suggestions would be much appreciated.
Checking log an exception: 'error 201 user not visible' was found.
Thanks in advance.
How about puting the api call into a variable and checking the variable.?
$result = $facebook->api($selectedid.'/feed', 'post', array(
'picture' => '',
'message' => $name."something",
'name' => $config['app_title'],
'link' => $config['redirect_uri']."?invitation=".$id,
'caption' => '',
'description' => '',
'actions' => array(array('name' => 'Get Search',
'link' => 'http://www.google.com'))
));
Because if it is successfull, it will send you back the id of the post.
The error was due the user not being able to post to his friends wall which I solved by doing a check before posting by running a fql to check 'can_post' to user's friends wall. Solution can be viewed at.
Check if a facebook user can post in his friends wall or not
I am desperately looking for image attachment php api feeds for my facebook app.
Basically what I am trying to do is send an image attachment, along with an automatic "post to friends wall" action.
The idea behind it is that a user sends a "virtual burger" to their friends wall, with a message offering them a discount.
This is a snippet of the code that successfully sends the message, but I can't get the attachment to work.
if($_REQUEST['friend_1']!='' && $_REQUEST['friend_1']!="Start typing a friend's name") {
try {
$fql1 = "select name from user where uid=" . $_REQUEST['friend_1'];
$param1 = array(
'method' => 'fql.query',
'query' => $fql1,
'callback' => ''
);
$fqlResult1 = $facebook->api($param1);
$friend_1_name = $fqlResult1[0]['name'];
$statusUpdate = $facebook->api('/'.$_REQUEST['friend_1'].'/feed', 'post', array('link' => $fanpageURL, 'name' => 'Have a virtual Unity Burger.', 'description' => " ".$user_name." just sent you a virtual Unity Burger. If you would rather have the real thing then come add your name on the Unity list and we will give you a 20% discount on your next visit and an exclusive Unity keyring.", 'properties' => '', 'cb' => ''));
} catch (FacebookApiException $e) {
//echo "Notification not send to user ".$fqlResult1[0]['name']."<br>";
I think there are two ways to attach an image to a wall post.
The first one is to define the meta og:image in the target page and post the link to the friends wall. Facebook will query the target and grab the Open Graph info displaying it in the wall. You can test this with the Facebook Debugger.
The meta property should look like this:
<meta property="og:image" content="http://url.to/image" />
You can also define other Open Graph properties like title, description, etc.
The second way to attach the image to the post is to include the picture parameter in the Graph API call. In your code you only define some parameters (link, name, description...) but you can also send picture, caption, message...
So your API call could be like this:
$params = array( 'access_token' => '',
'message' => '',
'link' => '',
'picture' => '',
'name' => '',
'caption' => '',
'description' => ''
);
$wallPost = $facebook->api('/'.$to.'/feed', 'post', $params);
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..!!!