API Foursquare javascript doesn't work - javascript

I'm trying to integrate Foursquare with my WebApp. I followed the instructions of Foursquare Developers Documentation but my app doesn't work(have the client ID, client Secret...)
Get the following error: "FoursquareClient not defined"
I have tried this:
the .html
<!DOCTYPE html>
<html DIR=ltr >
<head>
<title>Foursquare</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="viewport" content="width=320, initial-scale=1, minimum-scale=1, maximum-scale=1">
<script src="/html5/jquery-1.8.2.min.js" type="text/javascript"></script>
<script type="text/javascript" src="/html5/foursquare.js"></script>
<script src="https://ss0.4sqi.net/scripts/third_party/jquery.ba-bbq-eddd4adf74d0c1310a401475178c57df.js" type="text/javascript"></script>
<script src="https://ss1.4sqi.net/scripts/apisamples-35608dc9c26343e74f5d99fc20bae6c5.js" type="text/javascript"></script>
</head>
<body onload="return viewFoursquareLoad(event)" >
<div data-role="page" id="viewFoursquare" >
<table id="viewFoursquare_table"><tr><td>
</td></tr></table>
</form></div>
</body>
</html>
and the foursquare.js:
function viewFoursquareLoad(event) {
var client = new FourSquareClient("<3PMAYEX2KZ11R25GWV4WVP0IYEVWU01NVP49890KHA5OWJ21VVB>", "<PRQKBBE0N0VBUQTQ5R2F1UFGEYFZ322ZNVLHO88991MHC3I0O0VI>", "<http://url.com.br>", "<remember_credentials>");
client.venuesClient.venues("<IHR8THISVNU>", {
onSuccess: function(data)
{
alert(data.response);
},
onFailure: function(data)
{
alert(data.response);
// the request failed
}
});
}

Try without all the angle brackets.
var client = new FourSquareClient("3PMAYEX2KZ11R25GWV4WVP0IYEVWU01NVP49890KHA5OWJ21VVB", "PRQKBBE0N0VBUQTQ5R2F1UFGEYFZ322ZNVLHO88991MHC3I0O0VI", "http://url.com.br", "remember_credentials");
and
client.venuesClient.venues("IHR8THISVNU", {

Related

Java script google api to get authorization code

I done this code using tutorial but it does not work, it simply does open pop-up to enter your credentials for google. What is wrong with this code?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<button id="sign-in-button">Sign in</button>
<script src="https://apis.google.com/js/api.js"></script>
<script>
gapi.auth2.init({
client_id: "655720894976-2rkkoov9efteqna8hq3vbc632brur2jf.apps.googleusercontent.com"
});
document.getElementById("sign-in-button").addEventListener("click", function() {
// Get an authorization code
gapi.auth2.getAuthInstance().grantOfflineAccess({
scope: "https://www.googleapis.com/auth/cloud-platform"
}).then(function(response) {
var authorizationCode = response.code;
});
});
</script>
</body>
</html>

How can i get the profile and user information using google one tap signin

I am trying to get the profile information using google one tap sign in and i am getting the clientId and credentials instead of users profile and i have used other gapi method also but i am not able to get it can anyone suggest how to extract
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<script src="https://apis.google.com/js/platform.js" async defer></script>
<script src="https://accounts.google.com/gsi/client" async defer></script>
<script src="https://apis.google.com/js/client.js?onload=authorize"></script>
<script src="https://www.gstatic.com/firebasejs/5.0.3/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/5.0.3/firebase-firestore.js"></script>
</head>
<body>
<div
id="g_id_onload"
data-client_id="xxxxxx"
data-callback="handleCredentialResponse"
></div>
<script>
function handleCredentialResponse(response) {
console.log(response);
auth2 = gapi.auth2.init({
client_id: "xxxxxx",
scope:
"email profile https://www.googleapis.com/auth/plus.business.manage",
prompt: "none",
});
auth2.signIn().then(function () {
console.log(auth2.currentUser);
});
auth2
.grantOfflineAccess({
scope:
"email profile https://www.googleapis.com/auth/plus.business.manage",
})
.then(async function (resp) {
var auth_code = resp.code;
// here i am getting the authorization code
});
}
</script>
</body>
</html>

cannot write JSON result from webserive to html

So I retrieve a JSON result from a webservice(created with spring) which looks like this:
[
{"id":34,"nachname":"Mozart","vorname":"Wolfgang Amadeus","namenspraedikat":"","instrumentId":0,"geburtsdatum":"27.01.1756","herkunftsland":"Salzburg","sterbedatum":"05.12.1791","plz":null,"ort":null,"straße":null,"handy":null,"fax":null,"email":"","discriminator":"Komponist"}
]
I got a jsp file with following HTML markup:
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="js/repertoireController.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>Insert title here</title>
</head>
<body>
<div></div>
<div class="komponist-id"></div>
<div class="komponist-name"></div>
</body>
</html>
I want to add the "nachname" and the "id" from the JSON object to the divs with the classes: komponist-id and komponist-name
I tried the following which is from the springIo guides https://spring.io/guides/gs/consuming-rest-jquery/
$(document).ready(function() {
$.ajax({
url: "myurl"
}).then(function(data) {
$('.komponist-id').append(data.id);
$('.komponist-name').append(data.nachname);
});
});
Unfortunately it doesn't work. When i use alert(data.id) it shows that it is undefined what am I doing wrong?
The problem is that your JSON is an array. So you just need to get the first object of it like: data[0] and then get the id/nachname.
var data = [
{"id":34,"nachname":"Mozart","vorname":"Wolfgang Amadeus","namenspraedikat":"","instrumentId":0,"geburtsdatum":"27.01.1756","herkunftsland":"Salzburg","sterbedatum":"05.12.1791","plz":null,"ort":null,"straße":null,"handy":null,"fax":null,"email":"","discriminator":"Komponist"}
];
$(document).ready(function() {
$('.komponist-id').append(data[0].id);
$('.komponist-name').append(data[0].nachname);
});
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="js/repertoireController.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>Insert title here</title>
</head>
<body>
<div></div>
<div class="komponist-id"></div>
<div class="komponist-name"></div>
</body>
</html>

PhoneGap NFC reader on Android detecting tag but not displaying content on screen

I am trying to develop a program using PhoneGap. I would like to scan and display the tag ID from a scanned card.
When the app is built and deployed through build.phonegap.com and comes into contact with a tag the device vibrates but nothing shown on screen. Can anyone tell me what I'm doing wrong?
function ready() {
function onNfc(nfcEvent) {
var tag = nfcEvent.tag;
var tagId = nfc.bytesToHexString(tag.id);
navigator.notification.alert(tagId);
var y=document.getElementById("rand");
y.innerHTML = tagId;
}
function win() {
console.log("Listening for NFC Tags");
}
function fail(error) {
alert("Error adding NFC listener");
}
nfc.addTagDiscoveredListener(onNfc, win, fail);
}
function init() {
document.addEventListener('deviceready', ready, false);
}
HTML:
<!DOCTYPE HTML>
<html>
<head>
<meta name="viewport" content="width=320; user-scalable=no" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Scan NFC</title>
<link rel="stylesheet" href="master.css" type="text/css" media="screen" title="no title" />
<script type="text/javascript" charset="utf-8" src="phonegap-1.0.0.js"></script>
<script type="text/javascript" charset="utf-8" src="phonegap-nfc-0.4.1.js"></script>
<script type="text/javascript" charset="utf-8" src="main.js"></script>
</head>
<body>
<p>Please scan NFC tag</p>
<p id="rand"></p>
</body>
</html>
I suppose that you main.js has the function init and so on.
well the only thing that you need is add after you file main.js the call to function init
<script type="text/javascript" charset="utf-8" src="main.js"></script>
<script type="text/javascript"> init(); </script>

How to get alert notifications to function with Phonegap 1.1.0 and iOS5

I am upgrading a Phonegap App to Phonegap 1.1.0 (from 9.4) and building with the new iOS5 SDK and Xcode 4.2.
The same happens when trying PhoneGap 1.0.0 as well.
The app has an about button that launches a notification dialog, but it is not firing after upgrading.
Here is the HTML from the Phonegap App
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" charset="utf-8" src="phonegap.1.1.0.min.js"></script>
<script type="text/javascript" charset="utf-8">
function onDeviceReady(){
//do something
}
function OnPageLoad(){
document.addEventListener("deviceready",onDeviceReady,false);
}
function alertDismissed() {
// do something
}
function onAlertBtn()
{
navigator.notification.alert("Test Alert Message", alertDismissed, "Test Alert", "Done");
}
</script>
</head>
<body onload="OnPageLoad()">
<div align="center">
<FORM>
<INPUT type="button" style="font-size: 18px;" value="About" onClick="onAlertBtn();" >
</FORM> </div>
</body>
</html>
Any assistance would be appreciated.
Thanks
Ok, after considerable trial and error, a fix has been found!
Modify the source to be...
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no;" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<link href="css/style.css" rel="stylesheet" media="screen" type="text/css">
<script type="text/javascript" charset="utf-8" src="phonegap-1.0.0.js"></script>
<script type="text/javascript" charset="utf-8">
function onDeviceReady(){
//do something
}
function OnPageLoad(){
document.addEventListener("deviceready",onDeviceReady,false);
}
function alertDismissed() {
// do something
}
function onAlertBtn()
{
navigator.notification.alert("Test Alert Message", alertDismissed, "Test Alert", "Done");
}
</script>
</head>
<body onload="OnPageLoad()">
<div align="center">
<FORM>
<INPUT type="button" style="font-size: 18px;" value="About" onClick="onAlertBtn();" >
</FORM> </div>
</body>
</html>

Categories

Resources