Does anyone know why Yahoo Finance returns null for bid? - yahoo-api

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?

Related

Unable to get resonse from import contacts sendgrid API using python

Below is the call I am trying to make -
I used field mapping in below data -
data = {
"file_type": "csv",
"field_mappings": [
"_rf2_T",
"_rf0_T",
"_rf1_T",
"_rf10_T",
"w1_T",
"w45_T",
"w46_T",
"w44_T",
"w2_D",
"w43_T"
]
}
print("--data---",data)
response = sg.client.marketing.contacts.put(
request_body=data
)
#print("--data---",data)
print(response.status_code)
print(response.body)
print(response.headers)
and getting below error
{'errors': [{'field': 'contacts', 'message': 'at least one contact is required'}]}
I am expecting upload url and header from api call

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"
}

geocode don't show subpremise address Brazil

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

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.

Sending template emails in Magento

I'm creating a Magento Module that can be used to send emails in certain occasions of my website. I'm following the tutorial from Branko Ajzele and everything seems to work fine until I try to send the email where I get a false response from the Send function.
Below is the code I'm using along with the result returned:
public function sendAction() {
/*
* Loads the html file named 'custom_email_template1.html' from
* app/locale/en_US/template/email/activecodeline_custom_email1.html
*/
$emailTemplate = Mage::getModel('core/email_template')
->loadDefault('custom_email_template1');
// var_dump(Mage::getModel('core/email_template'));
//Create an array of variables to assign to template
$emailTemplateVariables = array();
$emailTemplateVariables['myvar1'] = 'Branko';
$emailTemplateVariables['myvar2'] = 'Ajzele';
$emailTemplateVariables['myvar3'] = 'ActiveCodeline';
/**
* The best part <img src="http://inchoo.net/wp-includes/images/smilies/icon_smile.gif" alt=":)" class="wp-smiley">
* Opens the activecodeline_custom_email1.html, throws in the variable array
* and returns the 'parsed' content that you can use as body of email
*/
/*
* Or you can send the email directly,
* note getProcessedTemplate is called inside send()
*/
$emailTemplate->setSenderName('my name');
$emailTemplate->setSenderEmail('example#domain.com');
$emailTemplate->setTemplateSubject('STATUS CHANGED');
var_dump($emailTemplate->send('example#domain.com'));
echo "<br>";
var_dump($emailTemplate);
exit("test");
}
The var_dump given by var_dump($emailTemplate); returns the object with all the information correctly as shown below:
bool(false)
object(Gp_Notify_Model_Email_Template)#82 (19) { ["_templateFilter:protected"]=> NULL ["_preprocessFlag:protected"]=> bool(false) ["_mail:protected"]=> NULL ["_designConfig:protected"]=> NULL ["_emulatedDesignConfig:protected"]=> bool(false) ["_initialEnvironmentInfo:protected"]=> NULL ["_eventPrefix:protected"]=> string(13) "core_abstract" ["_eventObject:protected"]=> string(6) "object" ["_resourceName:protected"]=> string(19) "core/email_template" ["_resource:protected"]=> NULL ["_resourceCollectionName:protected"]=> string(30) "core/email_template_collection" ["_cacheTag:protected"]=> bool(false) ["_dataSaveAllowed:protected"]=> bool(true) ["_isObjectNew:protected"]=> NULL ["_data:protected"]=> array(6) { ["template_type"]=> int(2) ["template_subject"]=> string(14) "STATUS CHANGED" ["template_text"]=> string(208) "
ActiveCodeline custom email example by Branko Ajzele
Hi there {{var myvar1}} {{var myvar2}} from {{var myvar3}}. This is just some example template to test custom email module.
" ["template_id"]=> string(22) "custom_email_template1" ["sender_name"]=> string(7) "my name" ["sender_email"]=> string(15) "phil#gproxy.com" } ["_hasDataChanges:protected"]=> bool(true) ["_origData:protected"]=> NULL ["_idFieldName:protected"]=> NULL ["_isDeleted:protected"]=> bool(false) } test
The thing is that although everything seems to go well the send function returns false and of course I never get to receive the email.
Is there something I'm forgetting to do like any configuration in the backend or something?
---- UPDATE ----
After some investigation I realized that there are no emails reaching their destination at all in my Magento installation which I thought they were, so figured I should start from there.
I have already added all the emails in the backend.
I checked the Locale (language) and changed it to english/US (which I read could be an issue).
Any advise?
Are u trying it on the localhost or the live site. If you are trying in the localhost then you need to correct in the php.ini file for the email setting.