I am trying to read a spreadsheet using a service account (I cannot use OAuth, which works, since the process will be running on a server to periodically check sheet data)
I tried several approaches. If I follow the example using oauth I can see the sheet values. However, I need the run the script without any GUI on the background.
I have found this tutorial https://github.com/juampynr/google-spreadsheet-reader
I have created a projec, service account, added viewer role, shared the spreadsheet with the service account email. Generated the key.
It seems that the test program can connect to the google services but the moment it request the spreadsheet the end result is "404 not found".
require 'vendor/autoload.php';
$service_account_file = '/secrets/readsheetmar2019-08b737d1c1cb._portfolio_test.json';
$spreadsheet_id = '1TAWybckPrnWlQxBZh0ScDsFOvftwi2dvTBNGarSdY30';
$spreadsheet_range = '';
putenv('GOOGLE_APPLICATION_CREDENTIALS=' . $service_account_file);
$client = new Google_Client();
$client->useApplicationDefaultCredentials();
$client->addScope(Google_Service_Sheets::SPREADSHEETS_READONLY);
$client->fetchAccessTokenWithAssertion();
$service = new Google_Service_Sheets($client);
//added by me
if ($client->isAccessTokenExpired()) {
print "expired\n";
}else{
print "not expired\n";
}
$result = $service->spreadsheets_values->get($spreadsheet_id, $spreadsheet_range);
var_dump($result->getValues());
Error:PHP Fatal error: Uncaught exception 'Google_Service_Exception' with message '
Error 404 (Not Found)!!1
When the access token retrieved by OAuth2 is used, the Spreadsheet of $spreadsheet_id = '1TAWybckPrnWlQxBZh0ScDsFOvftwi2dvTBNGarSdY30'; can retrieve the values.
When the access token retrieved by Service Account is used, Error 404 (Not Found)!!1 is returned.
If my understanding is correct, please confirm the following points.
Confirmation points:
As a test run, please set the range $spreadsheet_range = '';.
For example, it's $spreadsheet_range = 'Sheet1'.
If the error message of The caller does not have permission is returned, please confirm as follows.
Whether the Spreadsheet of 1TAWybckPrnWlQxBZh0ScDsFOvftwi2dvTBNGarSdY30 is sharing the email of Service Account.
If you didn't share the Service Account to the Spreadsheet, please share the email of client_email in the file of readsheetmar2019-08b737d1c1cb._portfolio_test.json to the Spreadsheet you want to access.
If the error message of Google Sheets API has not been used in project ### before or it is disabled. is returned, please enable Sheets API.
If this was not the solution for your issue, I apologize.
It appears that Google Finance Currency Converter has stopped working altogether. A week ago I started getting these email notifications from my Magento 1.9.2 store:
Currency update warnings:
WARNING: Cannot retrieve rate from https://finance.google.com/finance/converter?a=1&from=GBP&to=EUR.
WARNING: Cannot retrieve rate from https://finance.google.com/finance/converter?a=1&from=GBP&to=USD.
Those URLs are indeed no longer valid. Does anyone know if there are new URLs we can use, or do we need to configure a different service?
This link is not working anymore.
protected $_url = 'https://finance.google.com/finance/converter?a=1&from={{CURRENCY_FROM}}&to={{CURRENCY_TO}}';
I researched and found this codes.
Find this file:
app/code/local/Payserv/GoogleFinance/Model/Google.php
Replace the codes with this:
class Payserv_GoogleFinance_Model_Google extends Mage_Directory_Model_Currency_Import_Abstract {
protected $_url = 'http://free.currencyconverterapi.com/api/v3/convert?q={{CURRENCY_FROM}}_{{CURRENCY_TO}}';
protected $_messages = array();
protected function _convert($currencyFrom, $currencyTo, $retry=0) {
$url = str_replace('{{CURRENCY_FROM}}', $currencyFrom, $this->_url);
$url = str_replace('{{CURRENCY_TO}}', $currencyTo, $url);
try {
$resultKey = $currencyFrom.'_'.$currencyTo;
$response = file_get_contents($url);
$data = Mage::helper('core')->jsonDecode($response);
$results = $data['results'][$resultKey];
$queryCount = $data['query']['count'];
if( !$queryCount && !isset($results)) {
$this->_messages[] = Mage::helper('directory')->__('Cannot retrieve rate from %s.', $url);
return null;
}
return (float)$results['val'];
} catch (Exception $e) {
if ($retry == 0) {
$this->_convert($currencyFrom, $currencyTo, 1);
} else {
$this->_messages[] = Mage::helper('directory')->__('Cannot retrieve rate from %s', $url);
}
}
}
}
It seems to be intermittent (it shows if I load a page 10 times or so, but only once every 10 clicks). But I've personally started configuring other services. I am using bank API's (currently a Swedish one so it might not help you). But check with your bank, they usually have APIs.
Good luck!
Apparently Google doesn't offer this service anymore.
The main alternative looks to be:
Fixer.io API
Currencylayer API
Both offers 1000 request for free a month ( you need to create an account on their homepage )
Source: https://stackoverflow.com/a/8391430/716435
Google doesn't provide the currency converter API anymore. There are several alternative APIs offering currency conversion data. Some have been mentioned in posts already (Fixer, Currencylayer...)
Another option is SWOP currency exchange rate API, a fast, easy to use, reliable and transparent foreign exchange rate API made from developers for developers. Full disclaimer: I'm one of the developers of SWOP :)
The SWOP API offers current and historical rates for 180+ currencies. They are gathered directly from trusted sources (various Central Banks and other important banks).
The SWOP API has two endpoints, GraphQL and REST/JSON, for developer convenience.
There's a free plan allowing 1,000 requests per month.
The problem is with the link, google updated the api link recently, and I found success once on checking 10 times to the existing link. Try changing to this link https://www.google.com/finance/converter
see this https://www.techbuy.in/google-finance-api-currency-converter-not-working-updated-link-check-currency-converter/
I was facing same problem from last week. But new url solved my problem and now currency conversion working fine.
try this:
https://finance.google.com/bctzjpnsun/converter
Google's finance URL doesn't seem to work for now, I have prepared a workaround to use MSN Money (Microsoft's) API. It returns JSON so you can consume it using any programing language, I have put sample using PHP:
function msn($from, $to, $amount) {
$url = 'https://finance.services.appex.bing.com/Market.svc/ChartDataV5?symbols=245.20.'.strtoupper($from).strtoupper($to).'LITE&chartType=1y';
$request = curl_init();
$timeOut = 0;
curl_setopt($request, CURLOPT_URL, $url);
curl_setopt($request, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($request, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)');
curl_setopt($request, CURLOPT_CONNECTTIMEOUT, $timeOut);
$response = json_decode(curl_exec($request));
curl_close($request);
$rate = array_last($response[0]->Series)->P;
return $rate * $amount;
}
The above function accepts the currency that you currently have, the target currency and amount. Send's a GET request to MSN URL and parses the JSON to get today's exchange rate. Finally, it multiplies the rate with your amount to convert it to the target currency.
I hope this solves your need, the code has a lot of rooms for optimization I just gave you a simple implementation
For example, you can save the exchange rate in your database and use that rate for one day this way you will only call the API once a day.
I am using this script Send Google Form by Email v2.0 (Amit Agarwal) but Google script gives the following message:
"Methode ScriptApp.GetScriptTriggers" has been marked as outdated.
Is there an alternative methode?
Please use getProjectTriggers() instead of getScriptTriggers().
var triggers = ScriptApp.getProjectTriggers();
I'm using django-facebook's Open Facebook API to try to defer a post with an image to a facebook page. The (relevant part of the) code is:
graph_api = OpenFacebook(integration.long_lived_page_token)
message = "something"
picture = "http://example.com/image.jpg"
d = datetime.datetime.strptime('07-25-2014 06:40 pm UTC', '%m-%d-%Y %I:%M %p %Z')
timestamp = timestamp = int(time.mktime(d.timetuple()))
try:
facebook_response = graph_api.set('/{0}/feed'.format(
facebook_page_id), message=message,
link=picture, picture=picture,
scheduled_publish_time=timestamp, published=0)
except:
...
This seems to work fine (I get the post id on facebook_response) but when the time comes to post this scheduled post nothing happens. When I check at the facebook page I see an error saying 'Sorry, something went wrong publishing this scheduled post' and offers to delete it or post it then. So, I can't seem to figure out what am I doing wrong.
I found a similar question but it does not offer a good answer.
Oh, I forgot to say when I remove timestamp and published=0 parameters (i.e. I post on that exact moment), the post gets created and published on the page's feed.
We have consistently getting the following error today when using API V3.0 to retrieve TaxRate from QBO:
An application error has occurred while processing your request - Detail: System Failure Error: An unexpected error occurred while accessing or saving your data. Please wait a few minutes and try again. If the problem persists, contact customer support. - Error Code: 10000
Is this a temporary issue with the servers or has something changed in the API ?
Thanks
I tried both the taxrate endpoints(findById and Query) from ApiExplorer and got a successful response.
GetById - https://qb.sbfinance.intuit.com/v3/company/688779980/taxrate/2
Query - https://qb.sbfinance.intuit.com/v3/company/688779980/query?query=select * from TaxRate
Can you please give it a try from ApiExplorer and check if you are hitting the correct endpoints. Otherwise you can raise a support ticket mentioning your company's relamID.
EDIT
Standard BASE URL for V3 - https://quickbooks.api.intuit.com/v3/company
We get the following when we try this call using devkit -
https://quickbooks.api.intuit.com/v3/company/1119166485/query?query=select+*+from+TaxRate&requestid=faf9f5e207134f24930eef40c9b8a21a&
Thanks
There is a bug in .net devkit where IDSquery will not work for count.
You need to use the following lamda function until the fix is in place-
QueryService AccQueryService2 = new QueryService(context);
int accs22= AccQueryService2.Select(c => c).Count();
Refer:
https://intuitpartnerplatform.lc.intuit.com/questions/829658-how-to-select-count-from-invoice-using-idsquery-to-return-int?jump_to=comment_1941998
EDIT:
The team has identified this a bug. They will rectify this in the next release around 1 month from now.