Programmatically post on Facebook group - php

I'm trying to develop a little app for Facebook, and I'm facing a problem with the API.
After a few searches, I started to think the graph API doesn't allow to do what I wanna do...
Basically, I want to post automatically a message on a group wall. I have a website on which people can post their message. This community also has a Facebook group, and my point is to automatically post a copy of messages from the website, on the Facebook group. Each time a new message is submitted on the website, of course.
I know that apps and pages can’t post on a group wall by themself.
So, I considered creating a Facebook account, working like a bot, to post my messages on the group. I guess I have to get a long-lived access token for this user, and renew it manually when it expire. I don't want to have to login myself manually, but it's not a big deal if I have to renew my token time to time.
Is that even possible? Is there a better trick to do that?
I'm a bit confused by the Facebook API, and I'm sorry for this question. Even more because of the changes on the fb API...a lot of answers through the web are now deprecated. What I am looking for is a start -an idea- to be able to develop my app.
Thank you for your help :)

Yes, it is really simple:
First, You'll need access_tokenn with the offline_access permission (this way it will last for 2 months)
Then, store this access_token somewhere and do:
Post to group wall:
$fbk = new Facebook(...);
$bfk->setAccessToken($yourBotAccessToken);
$postId = $fbk->api("/$fbGroupId/feed/",'post',$message);
You can even post replies to the first post:
$fbk->api('/'.$postid.'/comments/','post',$reply);

Related

Post on a users wall on behalf of my app (not the user)

For several years i have managed to sort things out without posting my own question, but by readings others instead. However, after reading over 200 useless posts, i've decided it's time i get some help.
I'm building a facebook app, and what i wan't to do is extremelly simple to explain. I wan't to notify a certain user about some event in real-time. For example, "the tv show you want to watch starts in an hour". Unfortunately, facebook doesn't allow apps to send private messages to users (which was my first choice). The standard way of publishing on a users wall on HIS BEHALF is not good either, because no notification is triggered. Therefore, my idea is to post on his wall on behalf of the app (or any similar action that will trigger a notification).
I know about app requests, but they are not what i'm looking for either, as you can see, they do not match what i want to do.
Also please note that the event may be particular for each user, so making a post or something for EVERYBODY to see is not an option ("Peter, you have dinner with stacy in an hour").
Firstly, i want to know if posting on the apps behalf (or facebook page, or any other idea) is possible.
If it isn't, i would like to see any other ideas to sort this out. Remember, it's extremelly important to trigger the notification.
Thanks for your time reading this, but i have one last request.
Although what i want to do is pretty simple, there are plenty of similar issues being disscused, which may lead to confusion, so please be SURE that you fully understood what i am asking before answering.
Thanks again
What about opening an event and auto inviting the specific user to the event?
Events invites trigger a notification and the only thing you need is the user's email address which you can easily get.
I am not 100% sure if an app posting on your wall initiates a notification*. Although posting to a users wall on behalf of an app is certainly possible.
You can follow the instructions on this link, under the "App Login" title, and with that retrieve the correct access token you need to make calls as your app.
In order to have the functionality you specified, you'll have to request the offline_access permission from your users - this will allow you to post to your users wall even when he/she is not currently in or using your app. (or even logged into facebook)
*
Usually these posts on behalf of an app are user initiated - ie the user pressed "post to my wall."

How can I read a Facebook fan page with the Graph API?

A few more specifics:
We have a good amount of fans on my restaurant's page, but we'd like to run our own website as well, with the same content (specials, etc.,) as Facebook.
With that said, we'd like to continue posting our daily specials on Facebook, as about 3,000 people see those posts and we bring in a good amount of business from there.
I have a small PHP script I've written that can pull the posts off of the wall, verify who wrote them and look for a small #hashtag to verify that I want it posted on the main page of our website.
However, periodically my access token expires and, therefore, I suspect I'm not going about this correctly.
Does anyone have a good, reliable way to read posts from a Facebook fan page?
Thank you!
You can try changing Access Token expiry time with offline_access permission.
Facebook Permissions page mentions about offline_access;
Enables your application to perform authorized requests on behalf of the user at any time. By default, most access tokens expire after a short time period to ensure applications only make requests on behalf of the user when the are actively using the application. This permission makes the access token returned by our OAuth endpoint long-lived.

Facebook app - Post to wall with multiple users

I recently made my first facebook app which works as a "connection" for posting messages to different walls. I got it all working and I now want to test it with other users. If I want a second user to be able to post to the walls through my app what needs to be added? The users can perfectly login through my php script but they are being refused when they try to post to the walls.
Should the users be added in the "Roles" section of my app? If yes, then they have to be "verified developers"?
Thanks in advance.
Check this out this might help you - http://thinkdiff.net/facebook-connect/php-sdk-3-0-graph-api-base-facebook-connect-tutorial/
Or if you can post your code, then i can surely help you to make it available to any user to use your app to post on their walls
If the user wants to post anything to their walls using your application, then they need to grant publish_stream extended permission to your application and using their access_token, you can allow them to post anything to their walls from your application and not just one user, any number of users will be able to do it, so if you post your code, i can help you with it.

Posting to User's walls as application using Facebook PHP API

I've been building a web app that uses facebook integration for easier registration/login and notifications for the users. However, for the notifications I want to be able to post to a users facebook wall when something happens on our site.
Really I see two possible problems with doing this. First being that the user will most likely not be logged in to our website when the notification needs to happen. Second I have not found a way to post to the feed using any identity other than the current logged in user.
So to reiterate exactly what I'm trying to do. When some action takes place on my site involving Bob, I want the websites application to post on Bobs wall notifying him of the action as if the application is one of Bobs friends. From some of the things I've seen while researching this, it seems as if facebook might not treat applications like users and I might have to go through a page to accomplish what I want. But really I'm ok with that.
What you need to do is to ask for the offline_access permission. Then you can store their graph id property after they login/authorize to your site's database. Then you just post to that graph id instead of instead of /me. In your case you would then POST a request to the "$user_graph_id/feed" endpoint with whatever parameters you usually have.

How to remove 'via app' when posting on facebook page feed

When posting to the page wall (feed) through my application, under the post contents facebook adds '20 minutes ago *via my_app*'. This is a problem for my company, since they don't want the fans knowing the posting is done through an application, thus losing the personal touch.
Is there any way to lose the '*via my_ap*p' part of the post? These are some of the things I have tried:
I have given every possible permission on the page admin user, including 'manage_pages'
Have tried with the token returned from graph api me/accounts for that page / Impersonating pages
Please tell me, short of making a bot to do the whole thing, is there any way to do this through the facebook api.
Thank you for any help you can provide.
If you don't want the people to see which company you are, then Facebook is the wrong platform for you!
I'm pretty sure, you also would violate the terms of Facebook (Developer).
See what your competitors are doing. The largest company in this business has named their app "Publisher". When users click on this a page will open up that doesn't say anything about who created the app - actually it doesn't say anything at all. You could also use the name "Publisher" for your Facebook publishing app - in Facebook app names don't have to be unique.

Categories