i'm using this code to post to my application page as the page and not the admin:
$page_info = $facebook->api("/344722062246773?fields=access_token");
$attachment2 = array('message' => $row["nwmsg"],
'access_token' => $page_info['access_token'],
'name' => $row["nwnm"],
'caption' => $row["nwsubject"],
'picture' => 'http://itradegame.com/itrade/' . $row["nwposter"],
'description' => $row["nwtext"],
'actions' => array(array ('name'=> 'Play!','link'=> 'https://apps.facebook.com/itradee/')));
$result = $facebook->api('/344722062246773/feed/','post',$attachment2);
but the wierd thing is the users who likes the page can see the post on thier news feed but can't see it on the page itself.
why?
Because of the new timeline feature, posts by users (all except the page itself) will be listed under 'Recent Posts by Others on { PAGE_NAME}' section.
Please check the section.
Related
I'm using Facebook Ads API to create unpublished page posts. I have a problem when I try to publish those page posts which are videos with call-to-action button. I create unpublished page posts successfully and then I publish the unpublished posts from power editor, but it shows this message when I try to publish unpublished page posts I created:
Sorry, something went wrong. Please try again.
I tried to remove call_to_action from the code, posts get published without any problem. I'm using Marketing API integrated with my app and use user access token with those permissions:
manage_pages, publish_pages, ads_management, business_management, public_profile.
I need help to be able to publish unpublished posts (videos) with CTA button.
Here's the code I use:
$video_data = new AdCreativeVideoData();
$video_data->setData(array(
AdCreativeVideoDataFields::DESCRIPTION => '<DESCRIPTION>',
AdCreativeVideoDataFields::IMAGE_URL => '<IMAGE_URL>',
AdCreativeVideoDataFields::VIDEO_ID => '<VIDEO_ID>',
AdCreativeVideoDataFields::CALL_TO_ACTION => array(
'type' => AdCreativeCallToActionTypeValues::LEARN_MORE,
'value' => array(
'link' => '<URL>',
'link_title' => '<LINK TITLE>',
'link_caption' => '<LINK CAPTION>',
'link_format' => 'VIDEO_LPP',
),
),
));
$object_story_spec = new AdCreativeObjectStorySpec();
$object_story_spec->setData(array(
AdCreativeObjectStorySpecFields::PAGE_ID => '<PAGE_ID>',
AdCreativeObjectStorySpecFields::VIDEO_DATA => $video_data,
));
$creative = new AdCreative(null, 'act_<Ad_ACCOUNT_ID>');
$creative->setData(array(
AdCreativeFields::NAME => 'Sample Creative',
AdCreativeFields::OBJECT_STORY_SPEC => $object_story_spec,
));
$creative->create();
Hope to get help, Thanks!
To publish unpublished post through API, you can make a POST call like /?is_published=true.
For the error from PowerEditor, it is lack of information for me to share any insights. It would be preferable to file a bug to Facebook for this type of issues. You are safe to share more details in the bug tool and Facebook can also pull information from their logs for troubleshooting.
In case you do not know the link to Facebook Bug Tool. https://developers.facebook.com/bugs/
I have the following code to generate a facebook post for a page using graph api.
$page_info = $facebook->api("/$pageId?fields=access_token");
if (!empty($page_info['access_token'])) {
$attachment = array(
'access_token' => $page_info['access_token'],
'message' => $msg,
'name' => $title,
'link' => $uri,
'description' => $desc,
'picture'=>$pic,
'actions' => json_encode(array('name' => $action_name,'link' => $action_link))
);
$status = $facebook->api("/$pageId/feed", "post", $attachment);
Posts from one of my facebook pages look like below image.
link to image - How my posts look
Then i came across some other pages, whose posts look like below image. As you can see, these preview images are large and appear above the post. When we click them, we are redirected to another website's page. So i had to assume, we are not posting this as image. Please note that i need to post my link, big thumbnail and my custom description as shown in this image.
How to achieve this?
link to image - How my posts should look like
bigger images in facebook posts when posting
Use the Open Graph to create the custom stories.
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);
Sample code is appreciated, I can't seem to find any simple examples of this online.
Using the new Facebook PHP-SDK, it's very easy to accomplish this.
Requirements:
Extended Permissions, depending on your needs
Page ID
Now as I said, depending on your requirements you may need offline_access, manage_pages, but for now this is the simplest straight forward way of doing this:
After downloading the PHP SDK, and in the example.php file:
Acquire the publish_stream permission:
<fb:login-button perms="publish_stream"></fb:login-button>
After successful authentication, you post to the page wall the same way you do it for normal user profile (and with the same options too, message, picture, link, name, caption, description, source):
$page_id = '123456789';
$feed_array = array(
'message' => "Hello world!"
);
$page_post = $facebook->api("/$page_id/feed","post",$feed_array);
Result:
Please note that this approach requires you being an administrator of the page.
in this change the /me/feed/ to your page id, I did't try....Just check
$attachment = array('message' => 'some meesgae',
'name' => 'This is my demo Facebook application!',
'caption' => "Caption of the Post",
'link' => 'mylink.com',
'description' => 'this is a description',
'actions' => array(array('name' => 'Get Search', 'link' => 'google.com')) );
$result = $facebook->api('/me/feed?access_token='.$access_token, 'post', $attachment);