'post to Facebook' link - php

I have a webpage (shown in an iOS UIWebView, but that doen't really matter) that shows, among other things, the users high score.
I want to add a button that the user can push to share his high score (in the HTML via PHP) on Facebook; when the user presses the button, a pre-programmed message gets posted on their wall: "Look, my high-score on awesomeiPhoneGame is 523, Check it out ".
I would prefer to do this entirely in HTML instead of native iOS code, for several reasons. What's the easiest way to do this?

Try to look up at Facebook javascript SDK that mean FB.ui
and don't forget to show window that prompt the user to grant permissions to your application
(see also : OAuth Dialog)

Related

Invite friends to facebook app (not a game) preferably using PHP

I'm wondering if it is possible to allow a user to invite friends to join my app, even though it is registered as a fitness app and not a game through facebook. Does this even matter?
I'd like to use the facebook requests dialog, but I am being tripped up by the wording in the info section of this page: http://goo.gl/zfx4R where it says that the request dialog is only available to games on facebook.com.
If the requests dialog is not the answer, how should I go about allowing a user to invite their friends? If there is a PHP solution I'd prefer it.
Thanks for the help in advance
As far as I know, there are no features which are restricted to the "type" of app, so game versus app should make no difference.
You can open the FB.ui({method: 'apprequests'}) Facebook Javascript dialog on any web page, the app doesn't need to be in a canvas or page tab. The wording may be confusing, but what is meant is that, when a user does accept an invitation, they will be sent to the app canvas.
This means that you will need to configure your Facebook app to have a namespace (apps.facebook.com/<namespace>) and you will need to handle users coming from invitations at that point. What you do with them afterwards is up to you, you could redirect them to your website if you wish.
You should be aware that the Facebook Requests process is deliberately quite cryptic to avoid gaining information from users who don't want to be involved in your app. Unless you have a specific reason to track invitations, I suggest using the FB.ui({ method: 'feed'}) dialog with a target_id.
Because of this, there isn't and will not be a way in PHP to perform this. You will need to load the JS SDK onto your page and invoke the dialog, then allow the user to make their decision (whether using the 'feed' or 'apprequests' dialog).

How to post on Facebook user's wall every time the user uses the Facebook Application [duplicate]

This question already has an answer here:
Closed 10 years ago.
Possible Duplicate:
How to publish to a Facebook User's wall when user uses the App from my website?
I developed a Facebook application using PHP from my website. I would like that every time such user uses the application - a post is posted on his/her wall stating that they are using the application and a link to my website.
Can this be done? If yes, how?
If you have to do this then you should use the Dialog API: https://developers.facebook.com/docs/reference/dialogs/feed/
If you do this automatically, users may report your app which may cause Facebook to take it down. It's much better to use a dialog as you're prompting the user to post a message rather than doing it for them.
You might be looking for Open Graph functionality, that wraps up usage to and allows you to post custom stories like "Anna listend to Spotify." Note, you have to have extra permissions to post without a dialog, called "publish_stream."
As for posting on each usage, get the jQuery's document.ready() method and put your Javascript dialog publish bit in there.
This isn't recommended- it's quite annoying. Usually, you have the user post according to some action, or activity, that they want to share. Not just usage. By the way you asked your question, that's why I mentioned Open Graph. That's more accepted now.
(updated) to do via PHP, get the access token, which means forming the authentication url. Have the user "login", which will send them to Facebook to authenticate. When they revisit yoru site, they'll have a "code" which you exchange for an access token (documented on Facebook site). So, you'd have to keep track that the user is in their initial visit, with some kind of session state variable. When they come back after authentication, store their access token, and check to see if they're still on their first visit, then, display a form for posting to their wall. When they've filled out the form, use form submit to Facebook the publish information for the feed post.
This is also not recommended- even the examples on Facebook's site use a hybrid of PHP and Javascript to create the same functionality.
The best thing to do: use Javascript SDK, and use Open Graph.

PHP, Twitter and Facebook posting pre-populated form content posting to own wall

Not sure if this has been done before, but did some searching and could not find anything.
I would like to have an input box on my webpage, which has some pre-populated text and when a user clicks submit the text is tweeted on their own wall, this would be posted immediately if they have a twitter session open if not twitter will ask for the user to sign in. I guess this must be possible because it is similar to a share button.
Not being very good with twitter I'm not sure where to even start.
(Also if possible I would like to do the same but with Facebook as well).
Nb. App is to be developed using php.
Thanks
Both twitter and facebook have well-documented API to do this. However, you will probably need to use their system to have the user confirm what is about to be posted. You might also need to use some javascript, I don't the specifics of these API.
https://dev.twitter.com/
https://developers.facebook.com/
You cannot do this on facebook. We do not allow pre-filling of the message param on dialogs.

Posting Twitter/Facebook-Status without authenticating?

I'm currently working my way through the facebook-iphone-sdk and the MGTwitterEngine and I'm wondering why this all has to be so hard.
I'm not planning to access any data from the two social networks, just allow the users of my app to post a message as their status/update.
Now after I installed the facebook-iphone-sdk I realized they just send you to safari to authenticate at facebook and then back into your app.
Now this seems overly complicated for the users of my app, if they just want to post they don't have to go back.
Isn't there a way, I could just call something like
http://api.twitter.com/version/statuses/update?text="this is the new status text"
?
EDIT:
The first answer
http://twitter.com/home?status=[URL ENCODED TWEET].
is exactly what I need.
Unfortunately this works perfectly on the Laptop, though if you are not already logged in on the iPhone, you will be presented with a a screen where one has to press "login" once. (at the url "mobile.twitter.com/home?status=[]").
Pressing login there links you to "mobile.twitter.com/session/new" without the status argument and so once you are authenticated the status message is lost.
The URL you're looking for is:
http://twitter.com/home?status=[URL ENCODED TWEET].
This will open up a window of twitter and, if logged in, populate that tweet into the Tweet box.
For Facebook Share, the URL is
http://www.facebook.com/share.php?u=http://SHAREURLGOESHERE
There is lots of sample code that comes with the facebook-iphone-SDK. If you were to allow the user to pubish without authorizing it chances are apple would deny it.

How to programmatically "press" a 'Like' button through a Facebook Application?

I'm developing this Facebook Application and I was wondering if it's possible (and how) to programmatically, through the Facebook PHP Graph API, press some 'Like' button on some page?
Of course, this is optional on my application... I'm still not ready to really explain what application I'm doing, but it would be interesting to code such a feature.
Is it possible somehow?
By your description it sounds like you're trying to get a user to like something without the users knowingly clicking a like-button. This sort of interaction is not condoned by Facebook, I think. There are various black-hatty ways to accomplish this though, one fairly elaborate one is descriped here: http://www.liquidrhymes.com/2010/08/25/smoking-hot-bartender-is-some-smoking-hot-facebook-spam/
UPDATE Sorry, I might be wrong. If you get stream_publish extended permissions from the user, you might be able to like posts on their behalf by doing a POST to /POST_ID/likes. See Publishing to Facebook in http://developers.facebook.com/docs/api
You cannot do this. Facebok wont let you do a POST to /POST_ID/likes, you can only do a get request to retrieve their likes. What you are trying to do is a violation of facebook's TOS. I would suggest just adding a like button and "forcing" them to like before they continue with your application. However, in my opinion even that is kind of silly because they can instantly go unlike it after they have used your application.
i was looking for the same thing, but not to force a user into liking something, but actually for their own protection.
here is where i come from: on a web site (maybe on multiple pages) there is an "I Like" button, implemented as described by facebook.
each time a user goes to that page, the browser will make a request to facebook, throught the iframe that contains the button, providing all the info that we are used to from a web server log file.
if the user has in the past logged in facebook and not cleared the cache. the request will also contain the cookie indentifying the facebook user.
so even more then analytics, facebook know all about the user activity on those pages.
so i wanted the user to only give this info when they decide to.
my solution was to have a button (as graphic only) on the page. when the user clicks it a new frame should open and only there the facebook code should be executed.
obviously on the new frame i could not put the normal "i like" code, since that would require a 2nd click for the user. at this point i would need the "programmatically clicking of the i like button".
it is not an opengraph solution, but it works: the frame just does a redirect to
http://www.facebook.com/share.php?u=URL

Categories