I want to know uploaded images only a images its not have any type of hidden embedded data like other images or any IP address
Thanks
You can use the image as a button and call a JavaScript function. This function will need to call an API that will return the data you want.
<img onclick="javascript:getIPData()" src="China-Flag-256.png" />
<script>
function getIPData() {
var request = new XMLHttpRequest();
request.open('GET', 'http://freegeoip.net/json/', true);
request.onload = function() {
if (request.status >= 200 && request.status < 400) {
// Success!
var data = JSON.parse(request.responseText);
} else {
// We reached the service, but it returned an error
}
};
request.onerror = function() {
// Deal with connection error here
};
request.send();
}
</script>
will return:
{
"ip": "116.12.250.1",
"country_code": "SG",
"country_name": "Singapore",
"region_code": "01",
"region_name": "Central Singapore Community Development Council",
"city": "Singapore",
"zip_code": "",
"time_zone": "Asia/Singapore",
"latitude": 1.2931,
"longitude": 103.8558,
"metro_code": 0
}
You can check more services to request the IP from this other question How to get client's IP address using JavaScript only?
Related
Trying to use surveyjs with laravel and vue, but when I try to get the survey from a api does not work.
I'm getting the data from a api in laravel controller.
surveyshow.vue
<template>
<div>
<survey :survey="survey"></survey>
</div>
</template>
created () {
...
let url = `/api/edit/i130`;
axios
.get(url)
.then(response => {
surveyJson = JSON.parse(response.data.data.json);
console.log(JSON.parse(response.data.data.json));
})
.catch(function (error) {
console.log(error);
});
this.survey = new SurveyVue.Model(surveyJson);
if I replace the variable using a constant works.
var surveyJson = {
pages: [
{
"name": "Address",
"title": "Address",
"questions": [
{
"type": "text",
"name": "address1",
"title": "Street Address",
"autocompleteAs": "placeautocomplete"
}, {
"type": "text",
"name": "address2",
"title": "Address Line 2"
}
]
}
]
};
You have a problem with the asynchronous aspect of your code. There is a callback function, which runs when the request to your api completes:
...
.then(response => {
surveyJson = JSON.parse(response.data.data.json);
console.log(JSON.parse(response.data.data.json));
})
...
but you are trying to load the survey json "outside" of it. In other words, this runs before the api request's callback has had a chance to load the survey's JSON:
...
this.survey = new SurveyVue.Model(surveyJson);
...
You should move the line that instantiates your survey inside the callback, like this:
...
.then(response => {
surveyJson = JSON.parse(response.data.data.json);
window.survey = new SurveyVue.Model(surveyJson);
})
...
I have a server response which have a success object within the success object it returns a clubs list, I want to apply search filter on each club name, I am trying to apply filter but it only checks the value (True/false) and it does not update the list. whenever I entered a correct value nothing is happened but by entering a wrong value it set the list empty. please guide me how can I achieve this.
{
"success": {
"message": "CLubs fetch successfully",
"club": [
{
"id": 98,
"user_id": 62,
"club_name": "My New Club",
"address": "Current Location",
"phone": "098765432",
"photo": "RCU2yvC.png",
"latitude": "31.2411783",
"longitude": "121.5057067",
"about": "hello every one how are you",
"authentic": "23",
"available_date": "2022-06-15",
"available_timing": "Mon to Fri - 9:00 AM to 6:55 PM",
"sports": "[tennis, paddel]",
"amenities": "[lockers, free parkings, 4 courts available]",
"price": 9000
},
{
"id": 99,
"user_id": 2,
"club_name": "New Club",
"address": "api from postman",
"phone": "0303030303",
"photo": "hceDfyX.png",
"latitude": "1.28732832",
"longitude": "1.82727272",
"about": "nothing",
"authentic": "1",
"available_date": "2022-04-04",
"available_timing": "any",
"sports": "\"Tennis\",\"Paddle\"",
"amenities": "array(\"Vol\",\"BW\",\"Toyta\")",
"price": 2000
},],},}
TextEditingController searchNameController = TextEditingController();
late StreamController streamController;
late Stream stream;
var searchedClubList = <ClubModal>[];
var allClubsLists = <ClubModal>[];
String searchResult = '';
//------------> get all clubs apis
getAllClubList() async {
try {
streamController.add('loading');
var response = await http.get(Uri.parse(SharedAPIs.getAllClubsApis));
if (response.statusCode == 200) {
var jsonData = json.decode(response.body);
print('Club body is ----------> $jsonData');
ClubModal clubModal = ClubModal.fromJson(jsonData);
//--------> these two lists used for searching
searchedClubList.add(clubModal);
allClubsLists.add(clubModal);
streamController.add(searchedClubList);
print('DONE');
} else {
streamController.add('no club');
}
} catch (e) {
print('Exception Error is ====> ${e.toString()}');
}
}
searchOperation({required String enteredString}) async {
var finalResult = <ClubModal>[];
if (enteredString.isEmpty) {
searchedClubList = allClubsLists;
finalResult = searchedClubList;
} else {
finalResult = searchedClubList
.where((element) => element.success.club.any((element) => element
.clubName
.toLowerCase()
.contains(enteredString.toLowerCase())))
.toList();
}
setState(() {
searchedClubList = finalResult;
});
}
I'm attempting to invoke my api which is self hosted via ngrok. ngrok is working correctly because I can open the external https site in my browser and it loads up.
So, what do I have
slack form:
var request = require('request');
var RegisterMsgBuilder = function () { }
RegisterMsgBuilder.prototype.build = function (data) {
return {
"text": "Would you like to play a game?",
"attachments": [
{
"text": "Choose a game to play",
"fallback": "You are unable to choose a game",
"callback_id": "wopr_game",
"color": "#3AA3E3",
"attachment_type": "default",
"actions": [
{
"name": "game",
"text": "Chess",
"type": "button",
"value": "chess"
},
{
"name": "game",
"text": "Falken's Maze",
"type": "button",
"value": "maze"
},
{
"name": "game",
"text": "Thermonuclear War",
"style": "danger",
"type": "button",
"value": "war",
"confirm": {
"title": "Are you sure?",
"text": "Wouldn't you prefer a good game of chess?",
"ok_text": "Yes",
"dismiss_text": "No"
}
}
]
}
]
}
};
exports.RegisterMsgBuilder = RegisterMsgBuilder;
this produces a form in slack with 3 buttons.
I've set up interactive components with the following url:
https://xyz.ngrok.io/api/values
this url points to a new asp.net webapi project. I've not changed anything in here. Its got a controller which looks like:
namespace WebApplication2.Controllers
{
public class ValuesController : ApiController
{
// GET api/values
public IEnumerable<string> Get()
{
return new string[] { "value1", "value2" };
}
// GET api/values/5
public string Get(int id)
{
return "value";
}
// POST api/values
public void Post()
{
int x = 66;
}
}
}
clicking on a button in my slack message does nothing. How come?
Primarily, you haven't given any kind of response for the API to act on. All your controller seems to do on receiving a POST is set x equal to 66.
When someone clicks that button in-channel, a POST request will be made to your action URL. It'll contain some information about the button clicked, the original message, etc (https://api.slack.com/interactive-messages#responding). You don't seem to be pulling the values from the POST your app receives at all - you'll definitely need to do that.
Through many searches I've gotten the script in question to work as expected. If the user clicks on a button on my web page then a contact will be created in their Google Contact list (if authorized).
The problem I'm left with is that the authorization never expires. In that once successfully authorized the user can press the button many times, even come back to the page later in a different session, and it will never ask for authorization again.
Perhaps this is the intended behavior of the GoogleAPI but for my intended purpose I don't expect any more than 1 click and I would expect if the user came back to my page at a later time that they would be asked to authorize again.
Is this possible? I've tried the following ...
gapi.auth.signOut();
gapi.auth2.signOut();
gapi.auth2.disconnect();
revoking the token (see end of post)
... with no success.
Code can be found here:
https://jsfiddle.net/brian_hill/chvtmmjr/7/
function addContact(entry) {
var config = {
'client_id': '403037917634-qproaer1g5gcq83c941heo4q07olol23.apps.googleusercontent.com',
'scope': 'https://www.google.com/m8/feeds',
'cookie_policy': 'single_host_origin'
};
gapi.auth.authorize(config, function() {
insert(config, entry);
});
}
function insert(config, entry) {
gapi.client.request({
'method': 'POST',
'path': '/m8/feeds/contacts/default/full/',
'headers': {
'GData-Version': 3.0
},
'body': {
'entry': [entry]
},
'callback': function(data) {
if (data.hasOwnProperty('entry')) {
var msg = "Your Google Contacts have been updated to include ";
window.alert(msg.concat(data.entry.title.$t))
} else {
var msg = "Contact information could not be added for "
window.alert(msg.concat(entry.title.$t))
}
}
});
}
And the HTML
<script src="https://apis.google.com/js/platform.js" async defer></script>
<script src="https://apis.google.com/js/client.js"></script>
<body style="background-color:rgba(32, 177, 17, 0.3);">
<p>
The button below will add a contact to your GMail contacts</p>
<div style="width:150px">
<script>
function addJohn() {
var entry = {
"category": [{
"scheme": "http:\/\/schemas.google.com\/g\/2005#kind",
"term": "http:\/\/schemas.google.com\/contact\/2008#contact"
}],
"title": {
"type": "text",
"$t": "John Doe"
},
"content": [{
"type": "text",
"$t": "[Automatically Created]"
}],
"gd$email": [{
"rel": "http:\/\/schemas.google.com\/g\/2005#other",
"address": "john.doe#abcd.com",
"primary": "true"
}],
"gd$postalAddress": [{
"rel": "http:\/\/schemas.google.com\/g\/2005#home",
"$t": "123 Main Street\nOttawa, ON\nCanada"
}],
"gd$phoneNumber": [{
"rel": "http:\/\/schemas.google.com\/g\/2005#home",
"$t": "555.123.4567",
"primary": "true"
}]
};
addContact(entry);
}
function addJane() {
var entry = {
"category": [{
"scheme": "http:\/\/schemas.google.com\/g\/2005#kind",
"term": "http:\/\/schemas.google.com\/contact\/2008#contact"
}],
"title": {
"type": "text",
"$t": "Jane Doe"
},
"content": [{
"type": "text",
"$t": "[Automatically Created]"
}],
"gd$email": [{
"rel": "http:\/\/schemas.google.com\/g\/2005#other",
"address": "jane.doe#abcd.com",
"primary": "true"
}],
"gd$postalAddress": [{
"rel": "http:\/\/schemas.google.com\/g\/2005#home",
"$t": "321 Unknown Street\nOttawa, ON\nCanada"
}],
"gd$phoneNumber": [{
"rel": "http:\/\/schemas.google.com\/g\/2005#home",
"$t": "555.765.4321",
"primary": "true"
}]
};
addContact(entry);
}
</script>
<button onclick="addJohn();">Add Contact - John</button>
<button onclick="addJane();">Add Contact - Jane</button>
</div>
</body>
(Note: Due to the nature of the GoogleAPI authorization process, it doesn't appear to work through JS Fiddle on either Chrome or Firefox --- I did get it to work on Microsoft Edge).
Thanks in advance,
Brian
PS. Adding my attempt for using the 'revoke' option. Which still doesn't work (I still don't get re-prompted for authorization) but also sometimes it works (updates addresses) and sometimes it doesn't.
function addContact(entry) {
var config = {
'client_id': '403037917634-qproaer1g5gcq83c941heo4q07olol23.apps.googleusercontent.com',
'scope': 'https://www.google.com/m8/feeds',
'cookie_policy': 'single_host_origin'
};
gapi.auth.authorize(config, function() {
insert(config, entry);
}).then(signOut);
}
function signOut() {
$.ajax({
'type': 'GET',
'url': 'https://accounts.google.com/o/oauth2/revoke?token=' +
gapi.auth.getToken().access_token,
'async': false,
'contentType': "application/json",
'dataType': 'jsonp',
'success': function (nullResponse) {
window.alert('Disconnected');
},
'error': function (e) {
// Handle the error
console.log(e);
}
});
}
function insert(config, entry) {
gapi.client.request({
'method': 'POST',
'path': '/m8/feeds/contacts/default/full/',
'headers': {
'GData-Version': 3.0
},
'body': {
'entry': [entry]
},
'callback': function(data) {
if (data.hasOwnProperty('entry')) {
var msg = "Your Google Contacts have been updated to include ";
window.alert(msg.concat(data.entry.title.$t))
} else {
var msg = "Contact information could not be added for "
window.alert(msg.concat(entry.title.$t))
}
}
});
}
Try using the Revoke token instruction in OAuth 2.0:
In some cases a user may wish to revoke access given to an application. A user can revoke access by visiting Account Settings. It is also possible for an application to programmatically revoke the access given to it. Programmatic revocation is important in instances where a user unsubscribes or removes an application. In other words, part of the removal process can include an API request to ensure the permissions granted to the application are removed.\
To programmatically revoke a token, your application makes a request to https://accounts.google.com/o/oauth2/revoke and includes the token as a parameter:
curl -H "Content-type:application/x-www-form-urlencoded" \
https://accounts.google.com/o/oauth2/revoke?token={token}
I ran the example here: https://github.com/crossbario/crossbarexamples/tree/master/wss/python, and everything works fine.
However, the following case does not work for me:
The config.json file:
{
"controller": {},
"workers": [
{
"type": "router",
"realms": [
{
"name": "realm1",
"roles": [
{
"name": "anonymous",
"permissions": [
{
"uri": "*",
"publish": true,
"subscribe": true,
"call": true,
"register": true
}
]
}
]
}
],
"transports": [
{
"type": "web",
"endpoint": {
"type": "tcp",
"port": 9000,
"tls": {
"key": "server_key.pem",
"certificate": "server_cert.pem",
"dhparam": "dhparam.pem",
"ciphers": "ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AES:RSA+3DES:!ADH:!AECDH:!MD5:!DSS"
}
},
"paths": {
"/": {
"type": "static",
"directory": "../web"
},
"ws": {
"type": "websocket"
}
}
}
]
}
]
}
The web/index.html file is just to see if the TLS works:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Router</title>
</head>
<body>
This is a router.
</body>
</html>
I generated the certificate and everything works well if I connect to the website at https://127.0.0.1:9000. The page loads correctly.
However, I set up another project in node.js to try to register something.. (code taken from the page load count example)
The code in server.js:
var connection = new autobahn.Connection({
url: 'wss://127.0.0.1:9000/ws',
realm: 'realm1'}
);
connection.onopen = function (session) {
console.log("connected to WAMP router");
app.session = session;
// REGISTER a procedure for remote calling
//
function get_visits () {
return app.visits;
}
session.register('com.example.get_visits', get_visits).then(
function (reg) {
console.log("procedure get_visits() registered");
},
function (err) {
console.log("failed to register procedure: " + err);
}
);
};
connection.onclose = function (reason, details) {
console.log("WAMP connection closed", reason, details);
app.session = null;
}
connection.open();
Now, wss://127.0.0.1:9000/ws is the correct URL for the router, however I always receive the following:
WAMP connection closed unreachable { reason: null,
message: null,
retry_delay: 1.8090544409276008,
retry_count: 1,
will_retry: true }
It can't connect to the server.
I am sure some basic concepts are escaping me, perhaps you can lead me in the right direction.
If you are using a self-signed certificate, you'll need to tell your browser to trust it or the connection will fail at the TLS layer.
I recently added client-certificate support and a fully-worked example of this to the 'crossbarexamples' repository: https://github.com/crossbario/crossbarexamples/tree/master/authenticate/client_tls
In the above-linked example, you would import the intermediate CA certificate to your browser (or the self-signed root CA certificate).
If you add
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"
in in your server.js code then node.js should accept the self signed certificate. (See the discussion on an node.js issue here.