update facebook status with php/curl - php

I have a page on facebook and i want to be able to update my page when someone post a classifieds ad on my website.
currently the website in on my localhost [wamp] and am testing it from there
i have tried the solutions provided in the following websites but none of them seems to work
http://360percents.com/posts/php-curl-status-update-working-example/
http://www.barattalo.it/2010/03/01/php-curl-bot-to-update-facebook-status/
All am looking for is simple function to update my facebook page as such
Update_status(email,password,status);

1) You need a Facebook app.
2) You then need a long lived access token for your Facebook page.
3) Using that access token you can post to your page. [ You can have a cron job running that checks whether any user has posted any new content, if yes then use the access token to post to page ]

Related

Is it possible to add a post on a facebook page via the graph API without a Facebook App?

I want to post updates automatically to my facebook page from my PHP website.
Facebook seems to force me to create an App where users can login and then post stuff.
But I don´t need all that stuff, I just want to post to the facebook page directly via code.
I went "Ok, I´ll create an App", but now for them to give my app the needed permissions, they want me to give them a login so they can test my app and stuff ... Is there no simple way to just autopost something to my own Facebook page?

Facebook Graph API PHP SDK -> Grabbing data from public page without login

I apologize in advance if this question is horrible.
My goal is to have my website grab data (events) from one specific facebook page that I own, and then display that data on the appropriate website.
I'm new to the facebook graph API. I downloaded and set up the PHP SDK to use on my website.
I created the initial $fb object as it stated to do within the SDK "Getting Started" page.
However, the next step in the system is creating a way for users to "login" and with this it generates the required access token.
On my site, I have absolutely no reason to have a user login.
I am so lost, that I am not even sure what to ask.
I guess, what do I have to do so that I can get an authorization token that will grab public data, without having the visitors to the website authorize an app or login.
I have searched a lot over the last few hours, but the only thing i can find is the document on how to have users log in to get the access token.
Any answer or documentation linked would be so greatly appreciated. thank you.

Facebook Open-Graph API Subscription or Update Notification without App Permission

I'm relatively certain after reading the facebook Open Graph documentation that I can't have a web site 'subscripe' to a public page, unless that page installs my app. Let me know if that is wrong.
What I am trying to make is a photo gallery, pretty simple, but it grabs photos from a public 'page' such as a college or university.
I would like it to update itself anytime there is a change. I was hoping I could do it through the API, possibly using API updates/subscription
Facebook App Subscriptions -
but I don't think that will work. I'm using PHP, are there other ways to listen and see if there has been a change? Other than just firing off a function every now and then, using CRON or some other such server tool. I would think that facebook would probably also not like that behavior, though I'm not sure.
As of right now, I am able to grab JSON from a public page's photo gallery using the API and the photo gallery works just fine, I'm mostly just wondering what the optimal of having it update itself automatically is.
You are correct in assuming that real-time updates for pages require admin access to the page to work. You need a page access token to be able to subscribe to updates for a specific page, and such a page access token you can only get from users that have admin privileges for that page. (The page does not need to install your app as a tab any more, they changed the subscription process in that regard; but the page access token is still necessary. Basically you can say, you can not subscribe to updates for just any arbitrary page, it has to be “your” page.)
Apart from that, all you can do is check for new content by requesting the current data in a sensible interval.
you need to get page access token, which is granted when the user is one of the Page Admin, check the documentation on Facebook
https://developers.facebook.com/docs/graph-api/reference/page
look for this line
"access_token": "The access token you can use to act as the Page. Only visible to Page Admins"

How can I show my personal stuff from Facebook in my website?

I searched in Stack Overflow, Google, etc, but I can't figure out how to show my stuff from my Facebook on my website. I tried some solutions and each one prompted the login dialog and visitors had to log in and accept my application (I've created one to test).
Many answers here were too generic, I didn't understand them that is why I'm asking.
I want something that would let my website "log in" to Facebook and show my status or photos to visitors without them needing to accept an app or log in into Facebook with their account.
I tried a facebook-php-sdk example with my AppID and AppSecret and it asked me to log in.
Also, github.com/facebook doesn't have an SDK for Python similar to facebook-php-sdk
You could write a script (eg. using the FB PHP SDK) that uses a long-lived access token to fetch your FB data and then store the data in your backend database (or other store for your website). To Facebook, your script will look like an app and your machine will be the only 'user' of that app. Note, long-lived access tokens are good for 60 days max. You could also try using an App Access Token to fetch basic info. App Access Tokens don't expire.
This might not be exactly what you are looking for since you posted this with the php and python tag, but it might solve your problem.
If you're website is powered by the wordpress engine you can use If-this-then-that : https://ifttt.com/
It basically allows you to create "recipes" with something like:
if new status on Facebook then create post on wordpress
The post will not require others to log in to Facebook.
This is without writing a single line of code only a couple of mouse clicks. So I'm not sure if this satisfies your needs.

How can I build an API in PHP

Hello I am looking to build a basic API and application/apps system on my social network something like Facebook or other sites have, my site is in php/mysql. Here are some questions.
1)
Basically what I want to do is give a user a API key and secret. After I have these how can I use them in my php app to authenticate a user request which would come from there server?
2)
I can basically build an API to send a request to my server with CURL and get the result back to the page in XML or JSON or whatever, the problem is when sending the request the user would have to know the user ID they want to send to lookup data against, this is fine for an API but I am wanting to have an Apps section where the user's app site would be using the API and would be loaded into my site in the app section with an iframe, the problem is, I need to find a good way to make it where a logged in user on my site can go to the app section and go to an app and there username should be available to that page loaded in the iframe. Facebook and myspace do this somehow and many other sites; I am lost how to get around this hurdle.
Any help on any of this is really appreciated, thank you
Update:
I just had an idea, if I require a cookie to be set when a user visit's my site, then they would have a cookie and it could hold there User ID, then my API script could look for that cookie to exist and grab it's value?
If you plane on using an IFRAME, then no, your API hosted on a separate website (the website inside the IFRAME) would not be able to grab the cookie. The cookie is only visible on the website that it was set for.
I have only used Facebook API with the FBML (not the IFRAME,) but all they do their is basically replace what's in the page with the info that the "tag" is calling. I'm not sure if there is a better way, but you could possibly call a page on the app's server (say the app is hosted at http://example.com/app/, and you called http://example.com/app/?id=28318&name=John%20Maguire,) and have your API code handle it and turn it into a variable?
Maybe you should look into the source code of the Facebook API client.

Categories