geocode don't show subpremise address Brazil - geocode

how to collect room number information on a building in the google geocode?
in my search don't show. SUBPREMISE
example address: rua joao samaha 1385, sala 403 bl 02 sao joao batista, belo horizonte, MG, Brazil.
https://maps.googleapis.com/maps/api/geocode/json?address=

I'm a developer at SmartyStreets, an international address verification API provider. Here's the component information that we have on that address:
[
{
// preceding data omitted
"components":{
"administrative_area":"MG",
"building":"Bloco 02",
"dependent_locality":"São João Batista (Venda Nova)",
"country_iso_3":"BRA",
"locality":"Belo Horizonte",
"postal_code":"31520-100",
"postal_code_short":"31520-100",
"premise":"1385",
"premise_number":"1385",
"thoroughfare":"Rua João Samaha",
"thoroughfare_name":"Joao Samaha",
"thoroughfare_type":"Rua",
"building_leading_type":"Bloco",
"sub_building_type":"Sala",
"sub_building_number":"403"
},
// remaining data omitted
}
]
Does that information help?
https://smartystreets.com/docs/international#components

Related

Getting the index of a specif element in a complex list in flutter

I have a list of this structure List messages = [ [{body: QGB59WIO57 Confirmed. Your account balance was: M-PESA Account : Ksh0.00 on 11/7/22 at 12:42 PM. Transaction cost, Ksh0.00. Dial *334# now to get your stamped M-Pesa Statement., address: MPESA, timestamp: 1657532523000, status: failed}],
I/flutter ( 4659): [{body: QGB7A3UGAX Confirmed. Your account balance was: M-PESA Account : Ksh0.00 on 11/7/22 at 2:18 PM. Transaction cost, Ksh0.00. Dial *334# now to get your stamped M-Pesa Statement., address: MPESA, timestamp: 1657538312000, status: failed}] ]
I want to get the index of where timestamp is equal to 1657538312000 in this case the ondex of the second element of the list
I didn't fully get the structure but you should be able to do seomthing like
var index = messages.indexOf(messages.firstWhere((element) => /*your check here*/ ));

Soundcloud trackID by track URL address

I would like to add soundcloud widget to my app.
for that, I need to send parameters on the iframe src.
The problem is that soundcloud demands for TrackID rather than the URL address of the track, and my users won't be able to find this trackID on Soundcloud's UI.
How can I resolve TrackID by track URL address?
If it's possible only by using the API - then how can I register as a new app? It seems impossible now. Also what API call would I need to make to resolve this info?
Thank you.
Unfortunately, the SoundCloud API is indefinitely not accepting new registrations. Like the comment above, an easy alternative solution is if you use this URL, it will provide you with a wide/short player:
https://w.soundcloud.com/player/?url= + URL of track
Example: https://w.soundcloud.com/player/?url=https://soundcloud.com/chrisbjerken/you-still-have-my-heart
This works for both a single track or a playlist.
Like you I needed to fetch some track informations from a soundcloud url, however the use of the API can't be an option from my side (API closed since 2017). This is what I came up with to get the track ID.
<?php
// url test example
$url = "https://soundcloud.com/the-bugle/bugle-179-playas-gon-play";
// this link give some infos of the track
$infos_music_soundcloud = 'https://soundcloud.com/oembed?url='.urlencode($url).'&format=json';
$page_content = file_get_contents($infos_music_soundcloud);
if(!empty($page_content)){
$content = json_decode($page_content);
// now, the track ID is in the html iframe code. Lets get it.
$matches = array();
preg_match('/tracks%2F(.*?)&/s', $content->{'html'}, $matches);
echo "the track id is ".$matches[1];
}else{
echo "the track don't seems to exists. Please verify the link";
}
?>
You can get also track title, description, thumbnail, author name/url...
Hope it helps ;)
edit -
if the track is private, just make sure you give the private link (ie. with something like "/s-clUrZ" at the end)
Soundcloud has an API that can be invoked in order to resolve an URL.
If you have a valid client_id you can perform a GET request setting the url and your client_id as parameters.
https://api.soundcloud.com/resolve.json?url=https://soundcloud.com/tomer-maizner/forever-tel-aviv-pride-2018-anthems-mixed-by-tomer-maizner&client_id=CLIENT_ID
This will give you this response:
{
kind: "track",
id: 460976748,
created_at: "2018/06/20 16:25:14 +0000",
user_id: 8504856,
duration: 3570385,
commentable: true,
state: "finished",
original_content_size: 142800123,
last_modified: "2018/06/23 15:26:59 +0000",
sharing: "public",
tag_list: ""forever tel aviv" circuit "we party" mix pride "tel aviv"",
permalink: "forever-tel-aviv-pride-2018-anthems-mixed-by-tomer-maizner",
streamable: true,
embeddable_by: "all",
purchase_url: null,
purchase_title: null,
label_id: null,
genre: "Electronic",
title: "Forever Tel-Aviv - Pride 2018 Anthems (Mixed By Tomer Maizner)",
description: "The best of the best from the pride weekend in Tel-Aviv including tracks from all Forever Tel-Aviv superstars . Sagi Kariv / Tomer Maizner / Yinon Yahel / Tommer Mizrahi / Mor Avrahami / Elad Navon / Micky Friedman Enjoy!!! Tracklist : 1. Tomer Maizner Feat. Madame Meyhem - Unbreak My Heart 2018 2. N-Trance - Set You Free (Sagi Kariv remix) 3. Maître Gims – Mi Gna (Tommer Mizrahi Remix) 4. Micky Friedman - Eshebo feat Hila Ben Saadon (Original Mix) 5. Edson Pride - Freedom (Tomer Maizner Stanga Mash) 6. Netta - Toy (Sagi Kariv extended remix) 7. Arian Grande - No Tears Left To Cry Remix (DJ Aron Remix) 8. Steven Redant - Sunshine On My Shoulders (Tommer Mizrahi Remix) 9. Mor Avrahami - Kumei (Original Mix) 10 . Sissy That B.Y.O.B (Tomer Maizner Mashup) 11. Louie Vega - Diamond Life (Elad Navon & Niv Aroya Remix) 12. Hanna Hais - Je Ne Veux Plus Etre Ta Reine (Ranz Remix) 13. I Am Free (Yinon Yahel Remix)",
label_name: null,
release: null,
track_type: null,
key_signature: null,
isrc: null,
video_url: null,
bpm: null,
release_year: null,
release_month: null,
release_day: null,
original_format: "mp3",
license: "all-rights-reserved",
uri: "https://api.soundcloud.com/tracks/460976748",
user: {
id: 8504856,
kind: "user",
permalink: "tomer-maizner",
username: "TOMER MAIZNER",
last_modified: "2018/06/20 17:34:39 +0000",
uri: "https://api.soundcloud.com/users/8504856",
permalink_url: "http://soundcloud.com/tomer-maizner",
avatar_url: "https://i1.sndcdn.com/avatars-000234677748-voqr8o-large.jpg"
},
permalink_url: "https://soundcloud.com/tomer-maizner/forever-tel-aviv-pride-2018-anthems-mixed-by-tomer-maizner",
artwork_url: "https://i1.sndcdn.com/artworks-000363076815-gwll9g-large.jpg",
stream_url: "https://api.soundcloud.com/tracks/460976748/stream",
download_url: "https://api.soundcloud.com/tracks/460976748/download",
playback_count: 8696,
download_count: 0,
favoritings_count: 792,
reposts_count: 62,
comment_count: 5,
downloadable: false,
waveform_url: "https://w1.sndcdn.com/WoEUY48eF4tR_m.png",
attachments_uri: "https://api.soundcloud.com/tracks/460976748/attachments"
}

Does anyone know why Yahoo Finance returns null for bid?

I use the following link to retrieve data from Yahoo Finance.
https://query.yahooapis.com/v1/public/yql?format=json&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=&q=select%20*%20from%20yahoo.finance.quotes%20where%20symbol%20in%20(%22IBM%22)
{
"query":{
"count":1,
"created":"2016-12-17T10:53:58Z",
"lang":"en-GB",
"diagnostics":{+}, // collapsed
"results":{
"quote":{
"symbol":"IBM",
"Ask":null, <---- NULL
"AverageDailyVolume":"3605490",
"Bid":null, <---- NULL
"AskRealtime":null,
"BidRealtime":null,
"BookValue":"17.89",
"Change_PercentChange":"-1.89 - -1.12%",
"Change":"-1.89",
"Commission":null,
"Currency":"USD",
"ChangeRealtime":null,
"AfterHoursChangeRealtime":null,
"DividendShare":"5.60",
"LastTradeDate":"12/16/2016",
"TradeDate":null,
"EarningsShare":"12.27",
"ErrorIndicationreturnedforsymbolchangedinvalid":null,
"EPSEstimateCurrentYear":"13.50",
"EPSEstimateNextYear":"13.90",
"EPSEstimateNextQuarter":"2.52",
"DaysLow":"166.13",
"DaysHigh":"169.11",
"YearLow":"116.90",
"YearHigh":"169.95",
"HoldingsGainPercent":null,
"AnnualizedGain":null,
"HoldingsGain":null,
"HoldingsGainPercentRealtime":null,
"HoldingsGainRealtime":null,
"MoreInfo":null,
"OrderBookRealtime":null,
"MarketCapitalization":"157.97B",
"MarketCapRealtime":null,
"EBITDA":"17.54B",
"ChangeFromYearLow":"49.23",
"PercentChangeFromYearLow":"+42.11%",
"LastTradeRealtimeWithTime":null,
"ChangePercentRealtime":null,
"ChangeFromYearHigh":"-3.82",
"PercebtChangeFromYearHigh":"-2.25%",
"LastTradeWithTime":"1:09pm - <b>166.13</b>",
"LastTradePriceOnly":"166.13",
"HighLimit":null,
"LowLimit":null,
"DaysRange":"166.13 - 169.11",
"DaysRangeRealtime":null,
"FiftydayMovingAverage":"160.02",
"TwoHundreddayMovingAverage":"157.25",
"ChangeFromTwoHundreddayMovingAverage":"8.88",
"PercentChangeFromTwoHundreddayMovingAverage":"+5.65%",
"ChangeFromFiftydayMovingAverage":"6.11",
"PercentChangeFromFiftydayMovingAverage":"+3.82%",
"Name":"International Business Machines",
"Notes":null,
"Open":"168.97",
"PreviousClose":"168.02",
"PricePaid":null,
"ChangeinPercent":"-1.12%",
"PriceSales":"1.99",
"PriceBook":"9.39",
"ExDividendDate":"11/8/2016",
"PERatio":"13.54",
"DividendPayDate":"12/10/2016",
"PERatioRealtime":null,
"PEGRatio":"4.37",
"PriceEPSEstimateCurrentYear":"12.31",
"PriceEPSEstimateNextYear":"11.95",
"Symbol":"IBM",
"SharesOwned":null,
"ShortRatio":"6.77",
"LastTradeTime":"1:09pm",
"TickerTrend":null,
"OneyrTargetPrice":"156.62",
"Volume":"3524102",
"HoldingsValue":null,
"HoldingsValueRealtime":null,
"YearRange":"116.90 - 169.95",
"DaysValueChange":null,
"DaysValueChangeRealtime":null,
"StockExchange":"NYQ",
"DividendYield":"3.36",
"PercentChange":"-1.12%"
}
}
}
}
Does anyone know why the fields for Ask and Bid are null? I've only tested a few companies, but it seems to be with IBM only for the time being?

Redirect website to Hong Kong and Spain based on their ip-address?

I am trying to redirect the website according to their country region. how do I get the country code without using the geoip. Can any one help me?
Method 1
You can use geoIP for apache to redirect. The same has been answered here as well.
Method 2
Many times in shared hostings, you can not install additional modules. In those cases you can use a third party api service, like http://www.geoplugin.net/.
Here's a function to use get Country details:
function getLocationInfoByIp(){
$client = #$_SERVER['HTTP_CLIENT_IP'];
$forward = #$_SERVER['HTTP_X_FORWARDED_FOR'];
$remote = #$_SERVER['REMOTE_ADDR'];
$result = array('country'=>'', 'city'=>'');
if(filter_var($client, FILTER_VALIDATE_IP)){
$ip = $client;
}elseif(filter_var($forward, FILTER_VALIDATE_IP)){
$ip = $forward;
}else{
$ip = $remote;
}
$ip_data = #json_decode(file_get_contents("http://www.geoplugin.net/json.gp?ip=".$ip));
if($ip_data && $ip_data->geoplugin_countryName != null){
$result['country'] = $ip_data->geoplugin_countryCode;
$result['city'] = $ip_data->geoplugin_city;
}
return $result;
}
Ref.
You can use the above function to redirect users:
$visitor = getLocationInfoByIp();
if($visitor["country"]=="HK"){
//Redirect to Hong Kong Site.
}
elseif($visitor["country"]=="ES"){
//Redirect to Hong Kong Site.
}
Method 3
You can use Hostip APIs. More here.
http://api.hostip.info/country.php
US
http://api.hostip.info/get_html.php?ip=12.215.42.19
Country: UNITED STATES (US)
City: Sugar Grove, IL
IP: 12.215.42.19
http://api.hostip.info/get_html.php?ip=12.215.42.19&position=true
Country: UNITED STATES (US)
City: Sugar Grove, IL
Latitude: 41.7696
Longitude: -88.4588
IP: 12.215.42.19
http://api.hostip.info/get_json.php
{"country_name":"UNITED STATES","country_code":"US","city":"Sugar Grove, IL","ip":"12.215.42.19"}
http://api.hostip.info/?ip=12.215.42.19
[use the URL above for an example - XML too long to paste below]
I would suppose you have to ask some party to map the IP address into a locatio, thus check the other questions such as Identify country by IP addresss.
I would suppose that services doing this, are internally relying on multiple different services which are holding the regional data, thus it is really the easiest solution to use them, instead of trying to go finding the country in your own service.

Email sent using contact form displays admins "from" address, and not the visitors email

This page uses Drupals contact form to send emails: http://www.westlake.school.nz/contact
Problem is, the school staff use outlook. When they recieve email from parents etc, the email comes in as
"From: admin#example.com On Behalf Of
Westlake Boys High School"
In Gmail it comes in correctly such as
from Westlake Boys High School
parentsEmailAddress#yahoo.com
Unfortunately, I cannot tell the entire school staff to stop using Outlook and exchange.
Can Drupals drupal_mail function be altered in order to fix this?
From contact.pages.inc:
drupal_mail('contact', 'page_mail', $contact['recipients'], language_default(), $values, $from);
tmsimont explains on this URL (http://api.drupal.org/api/function/drupal_mail#comment-3243) that
the $from parameter will only alter the
From header, not the Sender, Errors-to
or Return-Path.
of the drupal_mail function that is used by contact_mail_page_submit.
with more details (code from the drupal_mail() function)
line 3 - $default_from = variable_get('site_mail', ini_get('sendmail_from'));
line 9 - 'from' => isset($from) ? $from : $default_from,
line 23 - if ($default_from) {
line 24 - // To prevent e-mail from looking like spam, the addresses in the Sender and
line 25 - // Return-Path headers should have a domain authorized to use the originating
line 26 - // SMTP server. Errors-To is redundant, but shouldn't hurt.
line 27 - $headers['From'] = $headers['Sender'] = $headers['Return-Path'] = $headers['Errors-To'] = $default_from;
line 28 - }
line 29 - if ($from) {
line 30 - $headers['From'] = $from;
line 31 - }
line 32 - $message['headers'] = $headers;
So to solve your problem you could implement hook_mail function (http://drupal.org/node/358855#comment-2079266)
More resources can be found here:
1 - http://drupal.org/node/656472
2 - http://drupal.org/node/861562
3 - http://www.nmglc.co.uk/content/overriding-drupals-mail-function