Whats the difference between APP ID and API key? - javascript

Can anyone please tell me whats the exact difference between App id and api key? I am basically trying to post the score of a game on facebook with the click of a button (game works offline on browsers) . This is the basic code meant for posting as mentioned in http://developers.facebook.com/docs/guides/web/
<html>
<head>
<title>My Great Website</title>
</head>
<body>
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js">
</script>
<script>
FB.init({
appId:'XXXXXXXXXXXXXXX', cookie:true,
status:true, xfbml:true
});
FB.ui({ method: 'feed',
message: 'Facebook for Websites is super-cool'});
</script>
</body>
(note: i replaced 'XXX..' with a 15 digit code what I have). This particular code throws an error something like this 'An error occurred with TestAndroid. Please try again later.' Can anyone help me to debugg this. Thanks.

Exactly. Theres no difference beetween this variable. As You may know (or not) APP ID name was used before Facebook made OAuth-authentication. Now they're trying to use API Key name, because since OAuth is using, APP ID name is obsolete :)

Related

Disable automatic login with Google OAuth 2.0 [duplicate]

This question already has answers here:
Force google account chooser
(5 answers)
Closed 1 year ago.
I'm developing a website on which I would like my users to log in with their Google account.
I managed to do it thanks to the Google API and the OAuth protocol. The documentation is very well done for the implementation of the "Connect with Google" button, the problem is that the documentation stops there.
When I click on the "Connect with Google" button, the OAuth authorization page appears, I log in with my account and everything works.
My problem now is this: If I log out (and it works) I am redirected to my login.php page (which is perfectly normal), but when I want to log in again, by pressing the "Login with Google" button, I no longer have the choice of which account I want to log in with, it automatically logs me in with the account I used just before!
This is very convenient but for me it's a huge problem, since if I have several Google accounts, how can I connect with this account and not another one? Normally the OAuth authorization page should ask me with which account I want to log in, right?
Thanks in advance for your help!
Here's my code for login.php page :
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<script src="https://apis.google.com/js/platform.js" async defer></script>
<meta name="google-signin-client_id" content="XXXXXXXXXXXXXXXXXXXXXXXXXXXX">
<link rel="stylesheet" href="../assets/plugins/toastr/toastr.min.css">
<script type="text/javascript" src='../assets/js/jquery.min.js'></script>
<script src="../assets/plugins/toastr/toastr.min.js"></script>
</head>
<body>
<h1>Connexion</h1>
<div class="g-signin2" data-onsuccess="onSignIn" data-onfailure="onFailure"></div>
<script>
function onSignIn(googleUser){
var id_token = googleUser.getAuthResponse().id_token;
verif_token(id_token);
}
function onFailure(){
toastr.error('Error !', '', {positionClass: 'toast-top-left'});
}
function verif_token(id_token){
$.ajax({
url: "connect.php?id_token="+id_token,
method: "GET"
}).done(function(response){
var response = JSON.parse(response);
if(response[0] == 1){
// success
window.location.replace('https://xxxxxxxx.xx/secret.php');
}else{
// error
onFailure();
}
});
}
</script>
</body>
</html>
You can use Disconnecting and revoking scopes to delete the association between your app and a user's account.
Just add this code in onSignIn() function
var auth2 = gapi.auth2.getAuthInstance();
auth2.disconnect();
For more information look to google docs from here

Hello.js example showing an error

I almost copy/pasted this example from the Hello.js website:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript" src="js/vendor/hello/hello.js"></script>
</head>
<body>
<script>
hello.init({
facebook : XXXXXXXXXXX, //Plz note that I replaced a correct ID with the XXXXXXXXXX
},{redirect_uri:'redirect.html'});
hello.on('auth.login', function(auth){
// call user information, for the given network
hello( auth.network ).api( '/me' ).then( function(r){
// Inject it into the container
var label = document.getElementById( "profile_"+ auth.network );
if(!label){
label = document.createElement('div');
label.id = "profile_"+auth.network;
document.getElementById('profile').appendChild(label);
}
label.innerHTML = '<img src="'+ r.thumbnail +'" /> Hey '+r.name;
});
});
</script>
<button onclick="hello('facebook').login()">Facebook</button>
</body>
</html>
But when I click the facebook login button the console always shows me this error:
Uncaught TypeError: Cannot read property 'response_type' of undefined
Am I missing something?
Thanks in advance.
You must first register as a Facebook Developer to get an Facebook Developer ID, then you can replace the facebook : XXXXXXXXXXX with your ID. Also you have to specify the return URL. eg.
hello.init({
facebook : 355555184404909, //eg. Facebook ID
},{redirect_uri:'http://yourDomain/return.html'});
you can also register yourself as a developer on these networks Windows Live or Google+
EDIT: Added how to register your domain to a the Facebook Website Platform
You must register your domain on Facebook Developer Settings to allow the library to redirect to your domain
Just enter your domain http://yourDomain on the "Website URL" field.
You need to create an app as a Facebook Developer (https://developers.facebook.com/apps). You can then retrieve your Facebook App's Client ID.
As shown in hello's official website:
hello.init({
facebook : FACEBOOK_CLIENT_ID,
},{redirect_uri:'redirect.html'});

Share This API Facebook Share Image not showing

I have the trio button social media share using Share This API. Everything is ok. They are all sharing right contents. But except for the facebook share image, it cannot be registered as part of the og properties. No image is shown when the facebook popup share shows up. Can someone help please? Thanks in advance!
I actually just followed the template given by client and I dont want to change API/plugin as much as possible. And I cant find any documentation of this kind of service in the API's site http://developer.sharethis.com/.
This is the code.
<script type="text/javascript" src="http://w.sharethis.com/button/sharethis.js#publisher=71dfd17f-04ad-4bd7-acfc-7a47e609cc6f&type=website&post_services=email%2Cfacebook%2Ctwitter&button=false"></script>
<script type="text/javascript">
var BASE_URL = "http://mydemosite.com/";
var shared_object1 = SHARETHIS.addEntry({
title:"My Site | This is showing in fb debugger",
url: BASE_URL,
summary:'My summary. This is showing in fb debugger.',
content:'My Content. This is showing in fb debugger.',
image: BASE_URL + 'share.png'
});
console.log(BASE_URL + 'share.png'); //This returns exactly the url of the image
shared_object1.attachChicklet("email", document.getElementById("share_email"));
shared_object1.attachChicklet("facebook", document.getElementById("share_fb"));
shared_object1.attachChicklet("twitter", document.getElementById("share_twitter"));
</script>
I also checked in facebook's debugger. No image was listed under og: properties.
https://developers.facebook.com/tools/debug
It now worked when I hardcoded also in my <head> tag:
<meta property="og:image" content="<?php echo $base_url; ?>share.png"/>

Google Custom Search "Popular Queries" BAD REQUEST ERROR

In Google CSE, when I attempt to get Popular Queries, I'm getting this error in the FireBug Console:
NetworkError: 400 Bad Request - http://www.google.com/cse/api/xxxxxxxxx:xxxxxxx/cse/xxxxxxx/queries/js?callback=(new+PopularQueryRenderer(document.getElementById(%27queries%27))).render .... .. ..
Why is it happening? I just simply copy/paste the code from Google:
<html>
<head>
</head>
<body>
<!-- CODE COPIED FROM GOOGLE : START -->
<div id="queries"></div>
<script src="http://www.google.com/cse/query_renderer.js"></script>
<script src="http://www.google.com/cse/api/XXXX184908680XXXX:xxxxywrndxx/cse/xxxtywrnxxx/queries/js?callback=(new+PopularQueryRenderer(document.getElementById('queries'))).render"></script>
<!-- CODE COPIED FROM GOOGLE : END -->
</bodY>
</html>
I just figured this out, at least for me. The code Google gives you is wrong. They give you the URL:
http://www.google.com/cse/api/USERID:CSEID/cse/CSEID/queries/js?…
This puts the CSEID in twice. I was able to get it working by removing the first instance of the colon and the CSEID:
http://www.google.com/cse/api/USERID/cse/CSEID/queries/js
I'm not surprised they got confused: they use the term User Id to refer to the User string, but they use the term CSE Id to refer to both the portion after the colon and the combined User Id + colon + CSE Id.

How can I make this code work for custom 'Facebook Like Box'

I found a tutorial with a demo on customizing the 'Facebook Like Box'; it works great on that demo. I grabbed the code, and inserted my page's ID via https://graph.facebook.com/ and inserted it in the sidebar code widget of my Wordpress site. It begans to load, then outputs this error;
'Could not retrieve id for the specified page. Please verify correct href was passed in.'
Where/how can I fix that in the code? Do I have to update the ID in another place as well?
Code:
<div id="facebook">
<div id="fb-root"></div>
<script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" type="text/javascript"></script>
<script type="text/javascript">FB.init("fd161b28d6338cb852d8ed87878f67c3");</script>
<!-- FBML <fb:fan profile_id="284177564941187" connections="18" width="403" height="360" css="http://line25.com/wp-content/uploads/2010/facebook/demo/style.css?5"></fb:fan> FBML -->
<script src="http://line25.com/wp-content/uploads/2010/facebook/demo/js/fbvalidate.js" type="text/javascript"></script>
</div>
Edit: I'm resorting to this code in attempt to solve my general question with 'Facebook Like Box' - https://stackoverflow.com/questions/7995678/facebook-like-box-close-thumbnail-padding-html5-iframe-v
Why are you using FeatureLoader? That's deprecated and marked for removal shortly.
The Like Box code can be obtained from https://developers.facebook.com/docs/reference/plugins/like-box/

Categories