yahoo finance YQL issue - connection error. link also does not work - yahoo

Does anyone else experience problems when connecting to a Yahoo Finance community table?
The YQL console gives me a connection error message. Do others have the same issue
YQL query:
select * from yahoo.finance.historicaldata where symbol = "YHOO" and startDate = "2009-09-11" and endDate = "2010-03-10"
The ichart link shows a Yahoo warning that has been on there for a long time now.
The ichart link warning:
Yahoo Will be right back...
Thank you for your patience.
Our engineers are working quickly to resolve the issue.
The YQL console output:
<?xml version="1.0" encoding="UTF-8"?>
<query xmlns:yahoo="http://www.yahooapis.com/v1/base.rng"
yahoo:count="0" yahoo:created="2017-05-18T01:14:26Z" yahoo:lang="en-US">
<diagnostics>
<url execution-start-time="0" execution-stop-time="1" execution-time="1"><![CDATA[http://www.datatables.org/yahoo/finance/yahoo.finance.historicaldata.xml]]></url>
<publiclyCallable>true</publiclyCallable>
<cache execution-start-time="3" execution-stop-time="3"
execution-time="0" method="GET" type="MEMCACHED"><![CDATA[ada24345cde45cf8aefbdeee1216fea1]]></cache>
<url execution-start-time="4" execution-stop-time="14"
execution-time="10" http-status-code="502" http-status-message="Connection refused"><![CDATA[http://ichart.finance.yahoo.com/table.csv?a=8&b=11&e=10&g=d&c=2009&d=2&f=2010&s=YHOO]]></url>
<query execution-start-time="3" execution-stop-time="15"
execution-time="12" params="{url=[http://ichart.finance.yahoo.com/table.csv?a=8&b=11&e=10&g=d&c=2009&d=2&f=2010&s=YHOO]}"><![CDATA[select * from csv(0,1) where url=#url]]></query>
<cache execution-start-time="15" execution-stop-time="16"
execution-time="1" method="GET" type="MEMCACHED"><![CDATA[50ca55b0c486cc3071c5561ad3a43711]]></cache>
<url execution-start-time="16" execution-stop-time="57"
execution-time="41" http-status-code="502" http-status-message="Connection refused"><![CDATA[http://ichart.finance.yahoo.com/table.csv?a=8&b=11&e=10&g=d&c=2009&d=2&f=2010&s=YHOO]]></url>
<csv>Column mismatch: [<!DOCTYPE_html>] vs font: 300 18px "helvetica neue, helvetica, verdana, tahoma, arial, sans-serif;</csv>
<query execution-start-time="16" execution-stop-time="57"
execution-time="41" params="{columnsNames=[<!DOCTYPE_html>], url=[http://ichart.finance.yahoo.com/table.csv?a=8&b=11&e=10&g=d&c=2009&d=2&f=2010&s=YHOO]}"><![CDATA[select * from csv(2,0) where url=#url and columns=#columnsNames]]></query>
<javascript execution-start-time="2" execution-stop-time="57"
execution-time="55" instructions-used="27497" table-name="yahoo.finance.historicaldata"/>
<user-time>58</user-time>
<service-time>53</service-time>
<build-version>2.0.118</build-version>
</diagnostics>
<results/>
</query>

Yahoo has officially confirmed that the Yahoo Finance API has been discontinued in the following thread in the Yahoo Help Community (see posts by username Nixon):
https://forums.yahoo.net/t5/Yahoo-Finance-help/Is-Yahoo-Finance-API-broken/m-p/250503#U250503

Related

outlook-addin html body support for outlook for mac 16.24

I am developing outlook add-in on Outlook for mac 16.24(19041401). I tried to insert html to meeting body. The html is href for skype in . When end user tried to use add-in change the the skype number, I tried to use outlook-addin to read the meeting html body. But I got 2 issues.
1. "" isn't in the html body like I inserted into the body.
2. The Skype href doesn't have "skype://xxxxx?call", just give me a . Anybody have the same issue with me?
I insert the body:
<div id="skypelink" style="vertical-align:middle;display: inline-block">
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUEAIAAABSe1YZAAAACXBIWXMAAAsTAAALEwEAmpwYAAAKTWlDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVN3WJP3Fj7f92UPVkLY8LGXbIEAIiOsCMgQWaIQkgBhhBASQMWFiApWFBURnEhVxILVCkidiOKgKLhnQYqIWotVXDjuH9yntX167+3t+9f7vOec5/zOec8PgBESJpHmomoAOVKFPDrYH49PSMTJvYACFUjgBCAQ5svCZwXFAADwA3l4fnSwP/wBr28AAgBw1S4kEsfh/4O6UCZXACCRAOAiEucLAZBSAMguVMgUAMgYALBTs2QKAJQAAGx5fEIiAKoNAOz0ST4FANipk9wXANiiHKkIAI0BAJkoRyQCQLsAYFWBUiwCwMIAoKxAIi4EwK4BgFm2Mkc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AKVCdBSomftjkzEKYXWnayiiiTN43usW95u1t6alDWuWZ3en9t/S+nuNYoDzL17b2c6FMYDJB8BAFdJai+n90crreZVtn5WM5TUnoIzxhjL2nbxkCgA37UMfAAY5wqOV5bVbrEvvxPmSGKx7DE7/XXvFMk+8psD31q60Fr2iSUFqJhrOQWUGoTGk4M9e2SVp9RkiO7Egwc/cETyQ+oL+6tzbLM6K26tkacBXASp82nXbaMVs9vGRqliQvK1pSS5bcK9akU6XdI1Q94KKJEwqUp8g0mk/JHYx0SAOjGz43h6mjY1LFmrI6mQIEEaCuwqJRw48OZucQnrfGvRmTKxtrHavFRKBJSDqALYetgAJRlnAVUy0oGRs2gNNfqUkEtKlnM6SwX+ypC3f6xLqOdnFgmTcrkLLqR38P28OVAA9H5D3BFlWi9pD5rN06QZLaHCTiWDFSANob4NqkjynjnnXpQSAIhHmAXQxKNqQW6UXmMq/y0hy2cyKUERQj3rNnnCRYB3Y+mj9db6lUyxikWzBqi5bqpDYoOub61S0plpCVRyonv82qk2LsqvloZ7axVkGDcQHry73qqH0fG9dKfhhpAAwP38V/b3AACRBCM6Iaa5AAAAAElFTkSuQmCC">
<span>Join Call</span>
</div>
Use outlook read the html body:
<p class=MsoNormal style='vertical-align:middle'><img border=0 width=13
height=13 style='width:.1354in;height:.1354in'
src="~WRS%7b2F8FB628-6315-8E46-8398-0F1A181C67F9%7d.fld/image006.jpg"
style='height:.135in;width:.135in'
alt="/var/folders/63/dwr3c3t12szbjc66m_kxk5300000gp/T/com.microsoft.Outlook/Content.MSO/41334F0E.tmp"><span
style='font-family:"Microsoft YaHei UI",serif'><span class=MsoHyperlink><span
style='font-size:9.0pt;color:#1AB394'>Join Call</span></span></span><span style='font-family:"Microsoft YaHei UI",serif'> </span></p>

How to specify background image with Thymeleaf?

I'm learning spring boot with thymeleaf. I've stored user object's profile image in the file system and only the URL of the image is part of the User object persisted in the database.
I've added the name and dpurl into the model, in order to access it from the template.
#GetMapping("/profile")
public String profileController(#AuthenticationPrincipal User activeUser, Model model) {
model.addAttribute("name", activeUser.getName());
model.addAttribute("dpurl", activeUser.getDpURL());
return "profile";
}
I'm able to access name from template using th:text="${name}"
However, I'm not able to specify background image using thymeleaf like this
<div id="dp-container" th:style="'background-image: url(' + #̣{dpurl} + ');'" >
this is resulting in error Could not parse as expression: "'background-image: url(' + #̣{dpurl} + ');'"
Update
Changed it like this
<div id="dp-container" th:style="'background-image:url(' + #{dpurl} + ');'">
Now I'm not getting any error but background image still not being displayed.How to specify background-image using Thymeleaf?
It probably needs to look like this:
<div id="dp-container" th:style="'background-image:url(' + ${dpurl} + ');'">
But it depends on what dpurl contains. Do you really need to use #{...}? Then you should use #{${dpurl}}.
To debug this, you should be looking at the source. it will reveal what your expressions are resolving too.
I got this to work:
<td th:style="'background: url(/images/aws2.png)'" class="fluid hero-image" >
Well, if you've got something more complex like needing to pass a variable into the url, you can try this:
<div id="profile_image" th:style="'background-image: url('+ #{'/view-profile-pic/' + ${result.profile_pic}} +');'"></div>
And in css, the image was displayed correctly with:
#profile_image {
margin: auto;
height: 200px;
width: 200px;
box-sizing: border-box;
border-radius: 100px;
background-size: cover;
}
I stumbled upon this solution when I wanted to display profile pictures received from search results.
You could try this too if none of the others work. Upload the image to some online store like a file sharing service or google drive and provide the link to the image as the url for your background-image property.
<div id="dp-container" style="background-image: url(Link to the image);" >

Displaying images from a RSS feed?

Came across the wikipedia rss feed for their image of the day. I'd like to plug that into a test I'm doing, so their image of the day re displays on this new site. Right now, through using a rss code generator site, I'm able to display only the text. For ex my feed sort of just looks like:
Wikimedia Commons picture of the day for May 17
Picture of the day View of the rich ceiling of the Vank Cathedral in Isfahan, posibly the most impressive christi...
But no photos display. Does anyone know an easy way of adjusting this code I'm using generated from http://www.surfing-waves.com/feed.htm to display images as well? Thanks much. -Wilson
rss link: https://commons.wikimedia.org/w/api.php?action=featuredfeed&feed=potd&feedformat=rss&language=en
code:
<!-- start sw-rss-feed code -->
<script type="text/javascript">
<!--
rssfeed_url = new Array();
rssfeed_url[0]="https://commons.wikimedia.org/w/api.php?
action=featuredfeed&feed=potd&feedformat=rss&language=en";
rssfeed_frame_width="180";
rssfeed_frame_height="250";
rssfeed_scroll="on";
rssfeed_scroll_step="6";
rssfeed_scroll_bar="off";
rssfeed_target="_blank";
rssfeed_font_size="12";
rssfeed_font_face="";
rssfeed_border="on";
rssfeed_css_url="";
rssfeed_title="on";
rssfeed_title_name="";
rssfeed_title_bgcolor="#3366ff";
rssfeed_title_color="#fff";
rssfeed_title_bgimage="http://";
rssfeed_footer="off";
rssfeed_footer_name="rss feed";
rssfeed_footer_bgcolor="#fff";
rssfeed_footer_color="#333";
rssfeed_footer_bgimage="http://";
rssfeed_item_title_length="50";
rssfeed_item_title_color="#666";
rssfeed_item_bgcolor="#fff";
rssfeed_item_bgimage="http://";
rssfeed_item_border_bottom="on";
rssfeed_item_source_icon="off";
rssfeed_item_date="off";
rssfeed_item_description="on";
rssfeed_item_description_length="120";
rssfeed_item_description_color="#666";
rssfeed_item_description_link_color="#333";
rssfeed_item_description_tag="off";
rssfeed_no_items="0";
rssfeed_cache = "cb57972543b240ba8193a1b654c72b22";
//-->
</script>
<script type="text/javascript" src="http://feed.surfing-waves.com/js/rss-
feed.js"></script>
<!-- The link below helps keep this service FREE, and helps other people
find
the SW widget. Please be cool and keep it! Thanks. -->
<div style="text-align:right; width:180px;"><a href="http://www.surfing-
waves.com/feed.htm" target="_blank" style="color:#ccc;font-size:10px">widget
#</a> <a href="http://www.surfing-waves.com" target="_blank"
style="color:#ccc;font-size:10px">surfing-waves.com</a></div>
<!-- end sw-rss-feed code -->

Creating a fast and simple image search with Google Images (iframe)

I am doing a university project involving a sort of social network for recipes.
In order to have the database populated by ingredients, I have written a simple form that may add them to the db. Ingredients contain an image which I'd like people to add.
In order not to have my website flooded with uploads, I was thinking about a small google images iframe in which people click on the image they want, so that I can display it by its link (I expect every ingredient to be within the very first results in google images).
My problem is that Google's toolbar (the one they introduced with Google+) is quite annoying, and it takes a lot of the space I want the iframe to occupy.
Are there any workarounds? :-)
That's kind of a "Forever alone" question (I have even got the Tumbleweed achievement on this one :V ).
I arranged something myself, so I'll share :-)
<!DOCTYPE html>
<html>
<head>
<style>img{ height: 100px; float: left; }</style>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$.getJSON("https://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=tex&callback=?",
{
unescapedUrl: "any"
},
function(data) {
$.each(data.responseData.results, function(i,results){
$("<img/>").attr("src", results.unescapedUrl).attr("id", "img"+i).appendTo("#images");
$("#img"+i).wrap($("<a/>").attr("href", results.unescapedUrl));
if ( i == 1 ) $("#images").append("<br />");
});
return false;
});
</script>
</head>
<body>
<table id="images">
</table>
</body>
</html>

Google Documents List API - How to Publish a Document

I'm utterly lost as to how one can programmatically publish a Google Document (specifically a spreadsheet).
I've read the Google Documents List API Protocol Guide and have found this:
http://code.google.com/apis/documents/docs/3.0/developers_guide_protocol.html#GettingRevisions
The next section of the article begins with 'Publishing documents by publishing a single revision' and this is where I found this example:
PUT /feeds/default/private/full/resource_id/revisions/revision_number
GData-Version: 3.0
Authorization: <your authorization header here>
Content-Length: 722
Content-Type: application/atom+xml
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:gd='http://schemas.google.com/g/2005'
xmlns:docs="http://schemas.google.com/docs/2007" gd:etag="W/"DkIBR3st7ImA9WxNbF0o."">
<id>https://docs.google.com/feeds/id/resource_id/revisions/1</id>
<updated>2009-08-17T04:22:10.440Z</updated>
<app:edited xmlns:app="http://www.w3.org/2007/app">2009-08-06T03:25:07.799Z</app:edited>
<title>Revision 1</title>
<content type="text/html" src="https://docs.google.com/feeds/download/documents/Export?docId=doc_id&revision=1"/>
<link rel="alternate" type="text/html"
href="https://docs.google.com/Doc?id=doc_id&revision=1"/>
<link rel="self" type="application/atom+xml"
href="https://docs.google.com/feeds/default/private/full/resource_id/revisions/1"/>
<author>
<name>user</name>
<email>user#gmail.com</email>
</author>
<docs:publish value="true"/>
<docs:publishAuto value="false"/>
</entry>
I have been retrieving document list feeds and CRUDing worksheets but I cannot get the publishing to work nor do I understand how it is supposed to work. My basic setup for establishing a connection to my feed and preparing the data to be PUT is as follows:
<?php
set_include_path($_SERVER['DOCUMENT_ROOT'].'/library/');
require_once 'Zend/Loader/Autoloader.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->setFallbackAutoloader(true);
$theId = 'my-worksheet-id';
$user = "my-gmail-account-name";
$pass = "my-gmail-account-password";
$service = Zend_Gdata_Docs::AUTH_SERVICE_NAME;
$client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service);
$service = new Zend_Gdata($client);
$xml = "<entry xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005'
xmlns:docs='http://schemas.google.com/docs/2007' gd:etag='W/\"DkIBR3st7ImA9WxNbF0o.\"'>
<id>https://docs.google.com/feeds/id/spreadsheet:$theId/revisions/1</id>
<updated>2009-08-17T04:22:10.440Z</updated>
<app:edited xmlns:app='http://www.w3.org/2007/app'>2009-08-06T03:25:07.799Z</app:edited>
<title>Revision 1</title>
<content type='text/html' src='https://docs.google.com/feeds/download/documents/Export?docId=$theId&revision=1'/>
<link rel='alternate' type='text/html'
href='https://docs.google.com/Doc?id=$theId&revision=1'/>
<link rel='self' type='application/atom+xml'
href='https://docs.google.com/feeds/default/private/full/spreadsheet:$theId/revisions/1'/>
<author>
<name>$user</name>
<email>$user</email>
</author>
<docs:publish value='true'/>
<docs:publishAuto value='false'/>
</entry>";
$putURL = "http://docs.google.com/feeds/default/private/full/spreadsheet:".$theId."/revisions/0";
$data = $service->put($xml, $putURL);
?>
Which results in a
Fatal error: Uncaught exception 'Zend_Gdata_App_HttpException' with message 'Expected response code 200, got 400 Invalid request URI
Can someone help me out? Has anyone successfully published a Google Document programmatically?
Assuming the document has already been created and has a document id of XXXX
What you need to do is send a "PUT" request with specific headers, and XML (an entry describing your document) as the body, to a specific URL.
Since you are not changing any content of the doc (only the meta-data), your target URL will look like this...
https://docs.google.com/feeds/default/private/full/XXXX/revisions/0
The first thing you need to do is authenticate with the proper Google service.
$client = Zend_Gdata_ClientLogin::getHttpClient(GDOC_LOGIN, GDOC_PASS,'writely');
Use the returned object to grab your auth token.
$auth_token = $client->getClientLoginToken();
In Zend/Gdata/App.php is a helper function for executing the PUT request.
Prepare parameters for this method like so...
$method = "PUT";
$url ="https://docs.google.com/feeds/default/private/full/XXXX/revisions/0";
$headers['GData-Version'] = '3.0';
$headers['If-Match'] = '*';
$headers['Authorization'] = "GoogleLogin auth = $auth_token";
$headers['Content-Length'] = '380';
$headers['Content-Type'] = 'application/atom+xml';
$body = <<<XML
<?xml version='1.0' encoding='UTF-8'?>
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:docs="http://schemas.google.com/docs/2007"
xmlns:gd="http://schemas.google.com/g/2005">
<category scheme="http://schemas.google.com/g/2005#kind"
term="http://schemas.google.com/docs/2007#spreadsheet"/>
<docs:publish value="true"/>
<docs:publishAuto value="true"/>
</entry>
XML;
$contentType = "application/atom+xml";
$remainingRedirects = 99;
Then call the helper function...
$app = new Zend_Gdata_App();
$app->performHttpRequest($method, $url, $headers, $body, $contentType, $remainingRedirects);
Good luck!
Let me know if this helps!
Ok... where do I start?
First of all, your URL is incorrect. (the resource ID you're using is for JSON/XML not URL)
you have
$putURL = "http://docs.google.com/feeds/default/private/full/spreadsheet:".$theId."/revisions/0";
and you should have
$putURL = "http://docs.google.com/feeds/default/private/full/$theId/revisions/0";
(you can omit . for concatenation if you use " as delimiters)
now there are other problems since you're manually creating a xml entry.
Your authorization header is missing.
In your XML you're using revision 1 but in your URL you have revision/0
value is manually written and I'm pretty sure you are not trying to publish a 2 years old file. Same for and
MUST MATCH the retrieved etag or you won't be able to perform any PUT request.
Now you can change these values manually assigning variables but I think it's better to use Zend GData structured returned object.
In any case:
Retrieve from google the document you want to publish.
Find the correct entry (in this case the entry with the ID https://docs.google.com/feeds/id/spreadsheet:$theId/revisions/1)
change docs:publish value property to "true"
send a put request with the modified entry
that should work
I am new at Zend_Gdata myself but have sucessfully uploaded to Google Docs.
I don't know if this is what you are after but here is my code:
$client = Zend_Gdata_ClientLogin::getHttpClient(
'my#googleDocsEmail.address',
'MyPassword',
Zend_Gdata_Docs::AUTH_SERVICE_NAME
);
$gdClient = new Zend_Gdata_Docs($client);
$newDocumentEntry = $gdClient->uploadFile(
$file,
null,
null,
Zend_Gdata_Docs::DOCUMENTS_LIST_FEED_URI
);
I hope this helps,
Garry
Google says that putted data is wrong and response you with code 400.
try to place this code
<?xml version='1.0' encoding='UTF-8'?>
before
<entry xmlns='http://www.w3.org/2005/Atom'...

Resources