Facebook publication from app to page wall invisible to others - facebook

I have a big problem, I try to publish a post from an Facebook app to a Facebook page wall.
I used this function to do so :
function Post_facebook($message){
include_once('php-sdk/facebook.php');
$app_config = array(
'appId' => '*********',
'secret' => '************');
$page_config = array(
'access_token' => '********',
'page_id' => '*********');
$facebook = new Facebook($app_config);
$params = array(
'access_token' => $page_config['access_token'],
'message' => $message);
$post_id = $facebook->api('/'.$page_config['page_id'].'/feed','post',$params);
}
Everything seems to be ok, but only I can see the posts.
When I'm on the wall everything seems normal, I see posts from the app. But if someone else goes on the wall, he won't be able to. Publication are set to 'Public' on privacy settings so I can't see why it's not working.
If I go to post URL (https://www.facebook.com/*****/posts/*****) from another account it says : page doesn't exist....

You need to disable sandbox-mode from your Facebook app's settings

Related

is it possible to post facebook page wall using a cron job?

Please don't vote and flag this quest. Please.
I am is the admin of the page. How can I post to that page wall using php SDK.
Is it possible or not?
the following code is posting as I post the page. I want the page itself post things to the wall.
<?php
include_once("inc/facebook.php"); //include facebook SDK
######### edit details ##########
$appId = '1157979879888106'; //Facebook App ID
$appSecret = '86403d4061433e23a0ouo9ec46a1405'; // Facebook App Secret
$return_url = 'http://xxxx.com/site/test'; //return url (url to script)
$homeurl = 'http://xxxx.com/site/index'; //return to home
$fbPermissions = 'publish_stream,manage_pages'; //Required facebook permissions
##################################
$page_id = "447126725331764";
//Call Facebook API
$facebook = new Facebook(array(
'appId' => $appId,
'secret' => $appSecret
));
//$fbuser = $facebook->getUser();
$publish = $facebook->api('/'.$page_id.'/feed', 'post',
array('access_token' => 'CAAQdLHAnOgoBAGAYZCIE09nfXaWZBXdMuwW5I379TjaWMZAQSUZCks9B4JfQyMXBEDN1CQZBaQJFeP44vWTGhic8AnkBgARge0AKJHIYgMdfDk16rq6ON496t0Phv6QtCmOR7t3wcybioNjxFkYctuN1ppDEBQdAObi6eIva0ZBTvAHJOWCSfcNicaVIZD',
'message'=> "Hello boss",
'from' => $appId,
'to' => $page_id,
'caption' => 'Caption',
'name' => 'Name',
'link' => 'http://www.example.com/',
'picture' => 'http://www.phpgang.com/wp-content/themes/PHPGang_v2/img/logo.png',
'description' => 'Hello boss'.' via demo.PHPGang.com'
));
?>
First of all, publish_stream is deprecated since many years. You really need to check out the Facebook docs, they state clearly that you need publish_pages and manage_pages to post "as Page".
That being said, that exact same question gets asked a LOT on Stackoverflow, so you can easily find a lot more information with the search function. In general, this is what you need to do:
Authorize the user with publish_pages and manage_pages
(Generate an Extended User Token)
Get a Page Token with /me/accounts
User that Page Token to post to the Page wall
More information about Access Tokens:
https://developers.facebook.com/docs/facebook-login/access-tokens
http://www.devils-heaven.com/facebook-access-tokens/

Post to facebook page from facebook page tab app

I want to post activities from page tab app to my own facebook page. I referred many documents to post message to app.
My php code :
$GLOBALS["facebook"] = new \Facebook_Facebook(array('appId' => $facebook_app_id, 'secret' => $facebook_secret,));
$page_info = $GLOBALS["facebook"]->api("/pageid?fields=access_token");
print_r($page_info);die;
if (!empty($page_info['access_token'])) {
$args = array(
'access_token' => $page_info['access_token'],
'message' => 'TEST'
);
$postId = $facebook->api("/pageid/feed", "post", $args);
But pageinfo variable has only id. I'm not getting access_token. Any idea what else need to be done?
We need manage_pages permission which we can get it using https://www.facebook.com/dialog/oauth?client_id=client_app_id&client_secret=9ea3e2eff7c65b1fcf1a633da&redirect_uri=YOUR_REDIRECT_URL&scope=read_stream,publish_stream,offline_access,manage_pages.
After that using above code we will get access token which can be used to publish to our page

Trying to post to facebook page with app but get "The user hasn't authorized the application to perform this action"

I am trying to write a script that will post an update to a facebook page timeline. I created an app and created a key for the app. I am using the code below:
require_once HOME_PATH . '/include/facebook/facebook.php';
$facebook = new Facebook(array(
'appId' => FACEBOOK_APP_ID,
'secret' => FACEBOOK_APP_SECRET,
'cookie' => true,
'scope' => 'publish_stream',
));
$user_id = $facebook->getUser();
$access_token = $facebook->getAccessToken();
$attachment = array(
'access_token' => $access_token,
'message' => 'this is my message',
'name' => 'name',
'link' => ROOT_URL . $blog_data['url'] . '.htm',
'caption' => $blog_data['title'],
'description' => $blog_data['title'],
);
if ($image = get_first_image($blog_data['body'])) {
$attachment['picture'] = $image;
}
$facebook->api(FACEBOOK_BLOG_PAGE . '/feed', 'post', $attachment);
i think this key is connected to the app and not to my user, so it sounds like i would have to grant the permission within facebook, but i have seen some other posts telling me that i need to do this in code. The examples aren't very clear.
I know similar questions have been asked but i haven't seen any clear answers yet. Can anyone please clarify this?
If you want to get user_id by this piece of code: $user_id = $facebook->getUser();
The first thing you need, is to login an user through a URL returned by $facebook->getLoginUrl(array('scope' => array('perm', 'perm2'))).
Also, notice, where I put permissions, which I require. Not into the Facebook class constructor, but into the method getLoginUrl.
And lastly, for posting into a page, you need publish_actions permission (not publish_stream).

Cannot post link to fb via app

If I post a link, it shows up ad posted by me as user. If I post a message, it shows up as posted by the page itself. Why is that? I need the link to show up as posted by the page, not me. The page is mine.
$attachment = array(
'access_token' => 'page-token-here',
'image' => $code->image_urls,
'name' => $code->title,
'link' => $short_url,
);
$page_id="page-id-here";
$res = $facebook->api('/'.$page_id.'/feed','POST',$attachment);

PHP SDK: Post to FB application's wall as the app itself

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.