Post to Facebook page feed without first liking the page - php

Is it possible to post to a facebook page feed without first liking the page?
I tried the feed dialog using something like the code below --
https://www.facebook.com/dialog/feed?app_id=X&to=Y&redirect_uri=Z
which resulted in an error "An invalid target was specified: Y. The target must be a page, event, or user that the actor can post on the wall of."
I also tried creating an access token from the page admin and then posting using the graph, but that resulted in the feed post coming from the admin and not the user who is posting.
I simply need the user to be able to post to the pages wall. Any ideas?
Thank you!

See the FB docs:
feed
This connection corresponds to the Page's Wall. You can create a link,
post or status message by issuing an HTTP POST request to the
PAGE_ID/feed connection. To see more details please see links, posts,
and status messages documentation.
To impersonate the Page when posting to the wall (i.e. post as the
Page, and not the current user), you must use a Page access_token with
the manage_pages and publish_stream permissions, as described under
Page Access Tokens above.
Posts may be targeted to countries, cities, regions or locales using
the targeting parameter. Please see Post for additional information.
edit:
Sorry, bad part above, correct is:
posts
Create
You can create a post on a Page by issuing an HTTP POST request to
PAGE_ID/feed with the publish_stream and manage_pages permissions and
the following parameters.

Related

Post to Page as another Page - Facebook API

I'm looking to have my app post to a non-owned Page AS one of the user's owned pages (owned-page Posted to non-owned-page's feed).
If you log in to Facebook as your page, you are allowed to do this on the desktop platform. However, my trials (and search) have returned that it's "not possible" to execute via Facebook Graph API.
Specifically when I execute the following POST:
/{target-page-id}/feed?message=test&access_token={owned-page-access-token}
I receive the following response from FB:
(#200) Posts where the actor is a page cannot also include a target_id\n other than EVENT or GROUP
Posting to Event or Group works, but doesn't allow me to post to a target page.
Any workarounds? Having a hard time grasping that you can do it on the desktop portal but not via the API
Thanks in advance!
You might try defining who is posting to the page by adding the query string: &from=[name of page]
Ex:
/{target-page-id}/feed?message=test&from=[PageName]&access_token={owned-page-access-token}

Fb page post to another fb page with graph api

is there any way that I post to my partners facebook page as my fb page? I didn't find any solution for that - I know how to post to page via graph api, but it seems that page-to-page feauture is blocked.
Anyone?
Leo
Disclaimer: I'm not sure it's a bug or by design. I already report a bug at https://developers.facebook.com/bugs/285031211633194 related to link type post at may 8 2013
Let's say you are the admin fanpage called "Iptv",so you want to post to fanpage "coca-cola".
The first step is get Page Access Token via /me/accounts API. (Put this Page Access Token inside Graph API explorer's access token field for test.)
Then you can't simply do http POST request to PAGE_ID/feed with message parameter, because you would get error message:
What you can do is post a 'link' type post, then you're able to post as page.
Success post to coca-cola page as another page called 'Iptv':

Facebook: How to update the status from the page profile?

I have a problem with cross-posting to Facebook. I can post some info to my personal wall (used parsing or Facebook API), but I need to post to the page of a group (ex: facebook.com/pages/$Pagename/$PageId ). (I am manager on this group and can post manually, but need the same functionality automatically from my site.)
And I have errors each time I try to do the posting automatically to my own group:(
1) When I use parsing I get message 'The post could not be shared.'
(from m.facebook.com/sharer.php?error=1&_rdr )
2) When I use parsing and send post-data through m.facebook.com/a/home.php?refid=$NumberID
I can post the message from the group page. But if the message contains a link, it is posted on behalf of my profile, but I want to make a post from the group page with link on my site.
3) When I make posting through Facebook API -- I get the error (#200) - "The user hasn't authorized the application to perform this action"
I make server authentication. And I want make this without permissions query of the current user (therefore tried parsing).
again:
I can update own(!) status through this three methods (with link too). I need update profile of my page (message with link).
Is it possible?
Thanks in advance.

facebook graph api determine if user likes url

I want to display a different message if a user is currently logged in to facebook and likes the current page. I understand:
FB.Event.subscribe('edge.create', function(response) {
// you like this
});
Which will fire when a user likes the page, but when you reload the page how do you determine they already like the current page?
Thanks!
I'm pretty sure you cant do what you want (in this context).
Take a look at this page : http://fbrell.com/fb.api/does-like
You'll see you need the user to approve a permission to view the likes.
It's a huge security risk to allow someone to see the 'likes' of a user - even for the current page. Think about it you can easily spoof the current page and pretend to be any page.
BUT...
What I recommend you do is just set a cookie for your own benefit (in javascript) when the user 'Likes' your page. Assuming you're getting a large percentage of your 'Likes' from this page then you can safely correlate the presence of the cookie with a 'Like'.
I've seen some security exceptions doing this, but it seems to work (at least in Chrome).
Sense you describe the page as "current page" I understand that it is in an iframe tab. If this is the case, signed request supplies you with that information as $decode_signed_request = array('page' => array('liked' => true/false)).
Otherwise you can supply a canvas page with the GET parameters fb_page_id, which should include the parameter fb_sig_added to the server request with a 0/1 depending on if the user is a fan of that page. (This may require disabling OAuth 2.0 in your migration settings)
If you are talking about the like social plugin with an open graph url, you can not readily find out if the user is a fan without an application installation. If you do have that you can do an api call to /me/likes which will return a list of all the likes that user has, and search for the id of the object you are testing for.
You're safer using the Graph API since Facebook is in the process of deprecating their REST API. So to get if a user likes your page, you will need the page ID and the access token of your app.
https://graph.facebook.com/me/likes/PAGE_ID?format=json&access_token=ACCESS_TOKEN
Where PAGE_ID is the page id you want to check.
and ACCESS_TOKEN is your apps access token.
From the Graph API you can get the likes of a user by his id, as:
https://graph.facebook.com/ID/CONNECTION_TYPE
so for getting the likes you put your access token and:
https://graph.facebook.com/me/likes?access_token=2222222222222222
then look for your page if it is liked or not.
However you can always try FQL queries which i didnt try for Likes actually.
I hope that helped.
save user id or third_party_id in database when the user liked the link
to Get third_party_id
graph.facebook.com/me/?fields=third_party_id&access_token=xxx
https://graph.facebook.com/{FB_USER_ID}?fields=likes.target_id(167584559969748)&access_token={VALID_ACCESS_TOKEN}
shows data if that user has liked that Facebook fan page.
or
https://graph.facebook.com/{FB_USER_ID}?fields=likes.fields(link)
shows a list of liked links, from where you can get the link you are looking for.
All of these need 'user_likes' and/or friend_likes permissions.

post on facebook page wall as facebook admin through facebook php api

I would like to post feed to facebook page wall as page admin. I can publish post to facebook wall with publish_stream from fb php api, but it is just as a normal facebook user. May I know how can I do likewise as a page admin (meaning that the post publish from facebook page and not from other fb user on the page wall)? Thank you. It is urgent.
Regards,
Benjamin
Just come across this question. This was a know bug within the Graph API which has now been addressed. There is an additional permission named manage_pages which has been added to the list of extended permissions. If you request this permission as part of your authentication process then you should be up and running.
Further information can be found in the documentation and the bug fix that has been put in place.
it is mentioned here.
If you want to post to Page Wall as Page, use page id in the UID not in the target_id.
Pages can't post to other pages.
If you want to post to Page Wall as Application, use page id in the target_id, and the app id in the UID here

Categories