How are we supposed to send requests on Facebook if Facebook is in the process of deprecating FBML? Is there another way?
Found it! (Well, I didn't, but my friend did.)
Facebook Requests Dialog - JavaScript SDK
Facebook was hiding it! :)
It's really cool. Much better than old requests. You can store custom data in them and access it through the Graph API!
Note to self: "Read the documentation thoroughly."
Currently there is no other way..Facebook is updating the graph api and message part.So you can use FBML itself for the current use.You can use request-form and multi-friend-selecto to send the request.
<fb:request-form
action="start.htm"
method="POST"
invite="true"
type="sample network"
content="This network is the best place on Facebook for viewing, sharing and giving
friends the highest quality stuff. Join me on this network!
<fb:req-choice url='http://www.facebook.com/login.php?api_key=<c:out value='${apiKey}' />'
label='Check out this network!' />
">
<fb:multi-friend-selector
showborder="false"
actiontext="Invite your friends to this network."
exclude_ids="<c:out value='${appUserFriends}' />"
max="20" />
According to this part of the documentation it will be possible to achieve through dialogues.
Please note, we are in the process of moving this functionality to Platform Dialogs which will remove the requirement for the use of FBML.
At the moment I couldn't find anything about inviting friends yet (Friend Dialog is misleading - it's about adding new friends) but I suggest you keep an eye on updates here.
I would say use FBML for now because it will take some time before it is officially deprecated (it was announced a long time ago) but check up on the new methods so that you can implement it as soon as possible.
And there is the option of the send button as a tag
http://developers.facebook.com/docs/reference/plugins/send/
This is not deprecated right???
Related
When I did InspectElement on Pinterest's facebook login button, I saw this:
<a href="/facebook/register/?scope=email,user_likes,user_birthday,publish_actions" class="BigButton facebook" data-network="facebook" data-callback-url="/facebook/register/">
<span class="logo"></span>
Facebook
</a>
I could not found anything related to calling Facebook JS SDK with APP_ID, setting cookie, session etc.
How is it implemented here? What are data-network and data-callback-url tags? Are they custom tags developed by Pinterest's developers?
How can implement with the same cleaner approach?
Pinterest is using server-side login. Hence, you will not find FB's client-side JS SDK based FB.login calls. However, they seem to be using the JS SDK for getting login status and that's why they have FB.init calls.
These 'data-' attributes are part of HTML5. A quick search will help you with documents on how to use it with JS/JQuery and how it simplifies the code. In their case, they are using the values for 'network' and 'callback-url' in JS to handle something (I don't see the code that you mention above to comment further).
I have a one site , there I want to place a Facebook share button after the sharing the url or link return back on the site and show the coupon instead of share button.
We are waiting for the answers.
If any one give the right answer or make the script , I will give the some bouns.
From the Facebook official documentation:
http://developers.facebook.com/docs/share/
The Share button has been deprecated in favor of the Like button, and
will no longer be supported. Please use the Like button whenever
possible to drive maximum traffic to your apps.
I don't know specifically how to redirect to your site, however I suggest you to switch to like button in any case
I'm no lawyer, but it appears that forcing a person to share something is not correct
https://www.facebook.com/promotions_guidelines.php
You must not
condition registration or entry upon the user taking any action using
any Facebook features or functionality other than liking a Page,
checking in to a Place, or connecting to your app. For example, you
must not condition registration or entry upon the user liking a Wall
post, or commenting or uploading a photo on a Wall.
You should have your corporate attorney take a look at this before proceeding further with forcing a share.
Like is easy to do and is explicitly permissible. See:
http://developers.facebook.com/docs/reference/plugins/like/
Facebook's sharer.php is no longer deprecated but I suggest you switch to using dialog/feed to steer folks back to your coupon.
<a id='fb-share' style='text-decoration:none;' type='icon_link' onClick="window.open('https://www.facebook.com/dialog/feed?display=popup&app_id=YOUR_APP_ID&link=THE_PAGE_WITH_THE_SHARE_BUTTON?&description=MY_AWESOMENESS&redirect_uri=THE_PAGE_WITH_THE_COUPON&picture=URL_OF_A_PRETTY_IMAGE', 'mywindow', 'toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=580,height=325');
return false;" href="javascript: void(0)">Share on Facebook</a>";
I can not find a TOS violation for offering coupons to those that like or share.
I am completely new to facebook api and working on a very small project. Before getting into details of their api doc, I wanted to ask a quick question.
My application needs login with a facebook userid/password, go to a friends wall / groups wall, crawl through all the wall posts and dump them in database for further analysis. A simple http client would do the trick if facebook weren't completely unusable without javascript. Since its going to be a desktop app, I am reluctant to go for a full fledged server based app.
So what should be the simplest way of crawling through FB friend / group wall? Please correct me if I'm asking the wrong question because I have Zero FB knowledge.
PS: I would like a java based library / wrapper but any language would do...
the current api has some serious bugs. Either you only get 50 items from the wall or only the items of the last 30 days, which comes first.
Please check the facebook developer bug list first. Developer Bug list
The Facebook Graph API would be the best solution, but if it is buggy, as Herr Kaleun pointed out, and you need more than 50 items or 30 days of posts, then I have another idea.
It may not satisfy your distribution requirements, but if it does you can implement this as a GreaseMonkey user script. GreaseMonkey is a system for web client automation that is javascript-aware. It lives in the web browser and is written and controlled by javascript, and can also pragmatically simulate a user affecting javascript. GreaseMonkey is a Firefox plugin, but Chrome also has native support for user scripts (the language is slightly different, but most GreaseMonkey user scripts will work in Chrome).
Ok, on a quick search, It seems that the answer is the FB Graph API. I can see there are wrappers of graph api in almost all language. For Java, I found the RestFB & BatchFB. Please feel free to refer to any more useful / advanced api if available.
UPDATE:
I couldn't find any extended permission set to access a user's group wall / a user's friends wall? is it atall possible with an Application?
Prerequisites:
Your group needs to be publicly viewable You need to have signed up to make a Facebook app, in order to get the APP_ID AND SECRET_KEY.
Then, (example in PHP, but should easily be transposed to another language):
$url =
"https://graph.facebook.com/{$group_id}/feed?access_token=APP_ID|SECRET_KEY";
$data = json_decode(file_get_contents($url));
foreach($data->data as $d)
{
?>
<div>
<a href="http://facebook.com/profile.php?id=<?=$d->from->id?>">
<img border="0" alt="<?=$d->from->name?>"
src="https://graph.facebook.com/<?=$d->from->id?>/picture"/>
</a>
</div>
<div>
<a href="http://facebook.com/profile.php?id=<?=$d->from->id?>">
<?=$d->from->name?></a>
on <?=date('F j, Y H:i',strtotime($d->created_time))?>
<br/>
<?=$d->message?>
</div>
</div>
<?
}
This will get the wall posts. As far as limits, I don't know.
I should have asked this in Facebook developer forum instead, but somehow I can't register to the forum and the Facebook connect feature is not working at the time I'm writing this.
Anyway, I am still confused whether to use Graph API or the old REST API for my Facebook app.
Generally, this is what I want to achieve in my app:
Get profile picture and name of the user.
Get profile picture and name of the user's friends who are also using my app.
Post into the user's stream.
Allow users to invite their friends to use the application.
Can someone provide me an insight, which one is better for my application?
As Renesis said, the Graph API covers exactly what you need for the first three steps.
For the fourth point, I've been looking at the API extensively for my own apps and have found out how to do it via FBML with the following code:
<fb:serverFbml>
<script type="text/fbml">
<fb:fbml>
<fb:request-form
method='POST'
type='join my Smiley group'
content='Would you like to join my Smiley group?
<fb:req-choice url="http://apps.facebook.com/smiley/yes.php"
label="Yes" />'
<fb:req-choice url="http://apps.facebook.com/smiley/no.php"
label="No" />'
<fb:multi-friend-selector
actiontext="Invite your friends to join your Smiley group.">
</fb:request-form>
</fb:fbml>
</script>
</fb:serverFbml>
http://developers.facebook.com/docs/guides/canvas/#requests
It seems as though Scott's incorrect when he says Graph incorporates everything the old REST API has:
"We are currently in the process
upgrading our core server API from the
old REST API to the more modern Graph
API. However, most of the methods
required for canvas applications to
integrate with Facebook have not yet
been upgraded to the new API. For the
time being, we recommend you continue
using the old REST API in canvas apps
instead of the new APIs for the sake
of completeness."
(I can only post one hyperlink, so it's the same one as the #requests hyperlink but in the 'Making API calls' section)
Not sure if this is the case with other methods of integration such as web or desktop apps, but so far it seems as though the Graph API has a little bit of catching up to do!
Edit:
To list the profile pictures of a user's friend, use the following:
Assuming you've already got the current user's ID
https://graph.facebook.com/**USER-ID**/friends?fields=picture,name&access_token=**ACCESS-TOKEN**
This will provide a JSON object with a list of the current user's friends containing the UID, name and a link to the small version of the profile picture.
I haven't found a way to retrieve the large picture version in a search yet so with that method, if you wanted the large version, you'd have to iterate through each user and use this:
https://graph.facebook.com/**USER-ID**/picture?type=large
Get profile picture and name of the user.
http://graph.facebook.com/[uid] for the name and http://graph.facebook.com/[uid]/picture is an always up-to-date link to the current picture. Also, if you have an access_token, you can query http://graph.facebook.com/me for data on the current user, whoever that is.
Get profile picture and name of the user's friends who are also using my app.
Not sure about how to get the specific friends only, maybe using FQL. However, note that you can get specific fields in the friends list (defaults to just name and id) by adding a fields parameter: .../friends?fields=id,name,picture
Post into the user's stream.
Perform an HTTP POST to http://graph.facebook.com/[uid]/feed with a body parameter. (see http://developers.facebook.com/docs/api#publishing)
Allow users to invite their friends to use the application.
Sorry, not sure on this one...
Use the Graph API as it incorporates everything that the old REST API had. Plus The new API is RESTful, and results are returned in JSON which is good!
I am working on writing a small Facebook application just for fun and learning. Unfortunately, the Facebook developer documentation, wiki, and samples leave much to be desired.
If my application is an iFrame app (PHP), can I use FBML within the page or do I need to use the XFBML? If I need to use XFBML, is there a repository of snippets somewhere that I could look through?
I am looking to add a friend selector box. For example, welcome to the app, pick an object, send it to 20 friends.
You would think a friend selector would be a stock component for Facebook apps, but apparently not.
I can use FBQL and CSS to define my own, but wouldn't standards and consistency be nice?
Is there a definitive, from the ground up, easy to follow Facebook app developers tutorial that covers the FBML tags, the XFBML tags and what goes where with examples?
I think in every answer I make to a Facebook question, I pretty much mention that "Facebook documentation sucks, so don't feel bad if you can't find something."
The answer is yes, you can definitely use FBML in an IFrame application. I do it routinely. Facebook is blurring the lines between IFrame apps and FBML apps with XFBML, which is great. Basically, XFBML is just regular FBML, except that it is parsed and rendered via the Facebook Connect javascript libraries. Because of this, you see a bit of a delay before an FBML control is rendered, but generally this isn't a big problem.
I'll give you an example of loading a friend selector straight from one of my IFrame apps. You'll see that it's surrounded by fb:serverfbml tags, which you need to render several of the more complicated FBML tags. The FBML items that don't need a fb:serverfbml tag around them are listed on the XFBML wiki page.
Anyway, some code:
<fb:serverfbml style="width: 650px;">
<script type="text/fbml">
<fb:fbml>
<fb:request-form
action="http://my.app.com/invite/sent"
method="POST"
invite="true"
type="My App Name"
content="You should use My App Name. All the cool kids are doing it.
<fb:req-choice url='http://apps.facebook.com/my-app'
label='<?php
echo htmlspecialchars("That sounds sweet!",ENT_QUOTES);
?>'
/>
" >
<fb:multi-friend-selector
showborder="false"
actiontext="Invite your friends to use My App Name."
exclude_ids="1234556,465555"
rows="3"
/>
</fb:request-form>
</fb:fbml>
</script>
</fb:serverfbml>
Escaping quotes gets a bit tricky with all the nested tags, so you have to watch that. You can see my example is from a PHP app, and I left an htmlspecialchars() escape call in there just for illustrative purposes (even though that particular string doesn't need escaping).
Anyhow, if you've got Facebook Connect already installed for your IFrame app, then this should work with a bit of tweaking. If you don't have Facebook Connect going yet, then follow the Rendering XFBML instructions on the XFBML wiki page.