YQL request returning Connection refused - php

The following PHP code (on Laravel) has been working for months until today, where I am now receiving a 502 error indicating connection refused:
$url = "https://query.yahooapis.com/v1/public/yql?q=select+%2A+from+yahoo.finance.quotes+where+symbol+in+%28%27YHOO%27%29&format=json&env=%20store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=";
$data = file_get_contents($url);
dd($data);
When I login to the Yahoo Developer Console to test, I'm able to query the public datatables just fine. However, when I attempt to use the console to access any of the community datatables like this, I am returned the following (this error occurs with all community datatables):
{
"error": {
"lang": "en-US",
"diagnostics": {
"url": {
"execution-start-time": "0",
"execution-stop-time": "7",
"execution-time": "7",
"http-status-code": "502",
"http-status-message": "Connection refused",
"content": "http://www.datatables.org/yahoo/finance/yahoo.finance.quotes.xml"
}
},
"description": "No definition found for Table yahoo.finance.quotes"
}
}
Using a different machine/IP address, I am able to access these community tables just fine as long as I remain anonymous. Once I login to the Yahoo Developer Console, the Connection refused message appears again.
I suspect it has something to do with Yahoo possibly blacklisting my IP address or throttling my account as I run this script for every stock (3,000) once per day.
I attempted to access the URL referenced in the error message content node and it appears this site is down. I'm not sure if this content node matters to the API, as I am able to access it from a different IP address.
I'm open to suggestions and recommendations on how I can determine/fix this problem.

Yahoo Community tables are stored in datatables.org,
and datatables.org is down; that's why there's a querying problem.
http://www.datatables.org

In one of the forum posts, a Yahoo employee has confirmed that the free EOD data has been terminated, and will not be reintroduced. Check out this thread and look for reply from Nixon. Yahoo is recently acquired by Verizon, and it must be the new direction.
However, if you check the Yahoo financial page, the CSV download link works, though differently now. It is through a new API that uses an authentication token "crumb" that is linked to a cookie when you access the page.
I have put together some quick Python3 code to download the same CSV as before through this new API. Please check out the GitHub project yahoo_quote_download.

Related

How do we call fetchVerificationOptions in the Google Business Verification API with the Google API PHP SDK?

I am currently working with various Google APIs. I already have approved access to the Google Business API and am successfully making several calls to its endpoints with the PHP SDK; even calls to some of the endpoints in the Business Verification API. However, when I make a request to fetchVerificationOptions of a defined location, I get a 400 error.
Google\Service\Exception
{
"error": {
"code": 400,
"message": "Request contains an invalid argument.",
"errors": [
{
"message": "Request contains an invalid argument.",
"domain": "global",
"reason": "badRequest"
}
],
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.rpc.BadRequest"
}
]
}
}
I have verified the location being passed in is correct and in the format of "locations/<LOCATION_ID>". I am using this same key in many other successful calls.
I've read all the documentation I can find on this subject many many times. The error makes me think the data I am sending in is wrong, but the documentation is pretty clear on what is expected - a language code and, optionally, a context. In my current case, the location is a CUSTOMER_LOCATION_ONLY type of business and requires a PostalAddress object be provided in this request via the context. The SDK makes this seem even easier with objects for each piece of the puzzle.
Here is my relevant PHP code:
$options = new FetchVerificationOptionsRequest;
$options->languageCode = 'en-US';
$context = new ServiceBusinessContext;
$context->setAddress($postalAddress);
$options->setContext($context);
$verificationOptions = GoogleBusinessProfileApi::getVerificationService()->locations->fetchVerificationOptions($locationName, $options);
I have verified that $postalAddress in the code above is an instance of Google\Service\MyBusinessVerifications\PostalAddress holding valid address details.
I have verified that $locationName in the code above holds the correct value; my location ID in the format of "locations/<LOCATION_ID>".
GoogleBusinessProfileApi::getVerificationService() in the code above returns an instance of Google\Service\MyBusinessVerifications with my Google Client and all the authentication stuff taken care of. I use this method for all of my interactions and they work perfectly normal. Plus, the error doesn't indicate there is an issue with this part.
It is also worth noting that on my Google API Dev Console, I can see these requests coming in and ending with a 400 response. Though, that is as far as the metrics seem to go. I cannot find any deeper, more detailed information about the requests.
I am looking for anything - direction, ideas, thoughts. Anyone else deal with this before? Am I missing something obvious? Is this an issue with my code or the API itself? Anyone know how I can dig deeper on the Google console for these errors?
Thanks!
The Solution:
Set PostalAddress sublocality to null.
The Details:
With the help of a colleague, we figured out what was going on. I changed the code to call the older, deprecated version of the API. This returned a much more useful error message stating that the US doesn't use sublocalities in their addresses. I was setting that on my PostalAddress object, so I changed it to always be null and the request worked - on both the old and new API.
There were a lot of frustrating points around this problem.
Error messages. The response from the "new and improved" API should be telling me as much if not more than the older version.
Documentation. No where that I could find stated anything about the sublocalities in the US for this particular request.
Help Available. At the time of writing any of this, googling anything about this topic returned essentially nothing.
Sublocalities. The way my system is set up is we actually use Google's Place Lookup to get a valid PostalAddress to ensure the data we send them is valid. In this case, the address we used was returned to us from Google... with a sublocality. The sublocality held the county name; something we do use in the US. So there was even less of a reason to think that would have been the problem. While I disagree with the accuracy of the error message, I really needed that to understand what the issue was.
While this doesn't seem to be a big issue on the web right now, I do hope that this can help someone else avoid some wasted time someday.
~Cheers~

Firebase Created Dynamic links from PHP API not showing in console

I have created firebase dynamic links from our PHP API. Created link showing with the response, but not showing in firebase console dashboard.
Please check below response from API.
{
"result": {
"shortLink": "https://sample-xyz.page.link/UVJLgCH12gCMNdu66",
"warning": [
{
"warningCode": "UNRECOGNIZED_PARAM",
"warningMessage": "Android app 'com.sample-xyz.beta' lacks SHA256. AppLinks is not enabled for the app. [https://firebase.google.com/docs/dynamic-links/debug#android-sha256-absent]"
},
{
"warningCode": "UNRECOGNIZED_PARAM",
"warningMessage": "We could not find Android package name 'test_bundle_v_1.0.54' in your Google project. [https://firebase.google.com/docs/dynamic-links/debug#app-not-in-project]"
},
{
"warningCode": "UNRECOGNIZED_PARAM",
"warningMessage": "There is no configuration to prevent phishing on this domain https://sample-xyz.page.link. Setup URL patterns to whitelist in the Firebase Dynamic Links console. [https://support.google.com/firebase/answer/9021429]"
}
],
"previewLink": "https://sample-xyz.page.link/UVJLgCH12gCMNdu66?d=1"
}
}
Please help me to resolve this issue.
As far as I understood, dynamic links created through the API won't show up in the console.
Only when going to Events>dynamic_link_first_open, dynamic_link_app_open or dynamic_link_app_update will you be able to view statistics coming into your app. Which is quite unfortunate.
But using the Google Analytics parameters when creating your dynamic link it should be possible to view some more/better statistics.

Detect Disposable Email with Garbage Domain

I am developing website using php/codeigniter.
I have downloaded a list of temporary email domains from github (https://gist.github.com/adamloving/4401361)
I integrated this to my website to filter and validate email address.But I noticed that some domains are garbage and cannot detect by the list provided.
Please image below.
Currently Im using this code to filter/validate emails:
public function is_temp_mail($mail='')
{
$this->db->select('domain');
$this->db->from('table_disposal_email_domains');
$domains=$this->db->get()->result();
foreach($domains as $domain)
{
list(,$mail_domain) = explode('#',$mail);
if(strcasecmp($mail_domain, $domain->domain) == 0){
return true;
}
}
return false;
}
How to block garbage domains.Please help.
One of the issue with disposable emails is that new domains are added daily. So, maintaining your own list isn't gonna be enough after a few days.
You can use the validator.pizza API, which is free and updated frequently.
Disclaimer: I made this API 😊
I wrote a simple API for determining the domains of temporary mails, all you need to determine the temporary mail is to send a GET request:
https://api.testmail.top/domain/check/data=example#mail.com&ip=8.8.8.8
with authorization header:
Authorization: Bearer XXXXXXXXXX.XXXXXXXXXX.XXXXXXXXXX
and in response you will receive a message like this if the mail turns out to be temporary:
{
"error": 0,
"result": false,
"message": "This domain is in Blacklist"
}
you will receive such an answer if the mail turns out to be trusted (something like gmail.com or yahoo.com):
{
"error": 0,
"result": true,
"message": "This domain is in Whitelist"
}
I have described error codes and more detailed instructions on this page
It would be good if you use a third party package to help you on blocking temporary email domains. You can use MailboxValidator API, which had 300 free API credits per month. You can use the free API key with MailboxValidator CodeIgniter Email Validation Package after sign up.
Disclaimer: I am working at MailboxValidator.

Riot API server callback

I am making website to organize tournaments in League of Legends game. I have problem with receiving data about completed games from automatic callback.
The steps which we take:
We register provider with tournament-v3:
http://example.pl/riotcallbackinfo
on server EUNE
and recive id=10xx
We register tournament, and create tournament code successfully.
tournamentId=256xxx
code: EUNE043bb-xxx4d390-xxxx-4f2c-xxxx-4dc266xxxxxx
3. We play game with generated tournament code and completed it successfully.
After the match we should receive some data to our url:
example.pl/riotcallbackinfo
but nothing is sending. We have log system to check every time someone call this url and there is no information about calling it by riot api.
We can get data about this completed game using match-api-v3 and it is looked, like game is finished successfully.
We tried to register also http://example.pl:80/riotcallbackinfo url, but with no success.
To backed we use Laravel PHP 5.4. The documentation says:
"The following ports are forwarded to your Homestead environment:
HTTP: 8000 → Forwards To 80"
Lobby events for this game are:
{
"eventList": [
{
"timestamp": "1498128797694",
"summonerId": "23509512",
"eventType": "PracticeGameCreatedEvent"
},
{
"timestamp": "1498128833935",
"eventType": "GameAllocationStartedEvent"
},
{
"timestamp": "1498128803131",
"eventType": "ChampSelectStartedEvent"
},
{
"timestamp": "1498128798414",
"summonerId": "34477543",
"eventType": "PlayerJoinedGameEvent"
},
{
"timestamp": "1498128834399",
"eventType": "GameAllocatedToLsmEvent"
}
]
}
We have tested our url method with Postman and sending your sample JSON response and everything worked fine. Even if our method is broke we should see something in log. Our log is set at the beginning of the method.
Could you suggest us, were could have problem? Why couldn’t we get data from automatic callback? There is problem with our URL or is something what we understand wrong?
Thank you in advance for your help

How to get curl "Authorization token(OAuth token)" programmatically (using JS/PHP ) for github user?

I am working with Github now.How can i suppose to get the "OAuth token" for github login user.Now i have the Data like client_id,Client Secret,access_toke(these all data getting after login to github only).how can i get the OAuth token through the above data.
I got oauth toke through command line like:
[root#localhost Dinesh]# curl -u 'DineshGK' -d '{"scopes":["repo"],"note":"Help example"}' https://api.github.com/authorizationsEnter host password for user 'DineshGK':
[root#localhost Dinesh]# curl https://api.github.com/authorizations --user "DineshGK" --data '{"scopes":["user"], "client_id":"...", "client_secret":"..."}'
Enter host password for user 'DineshGK':
{
"id": 2300973,
"url": "https://api.github.com/authorizations/2300973",
"app": {
"name": "SenchaPlayground",
"url": "http://192.168.1.56/OldPlayground/"
},
****"token": "..."**,**
"note": null,
"note_url": null,
"created_at": "2013-04-16T07:34:21Z",
"updated_at": "2013-04-16T07:34:21Z",
"scopes": [
"user"
]
}
I want that Highlighted token pragmatically(using JS/PHP)..
Can any one help...
Thanks in advance ....
Please edit your question to remove your "client_id", and the token returned. Also, please go to your app settings and get a new "client_secret". None of that information should ever be made public to ANYONE.
Now, if your intent is to use cURL from JavaScript or PHP, you're going to have a very bad time. I would look into the how to make HTTP/1.1 requests in each and check out some of the existing libraries for either PHP or JavaScript that wrap the API for you. With those in hand (having never used any of them in all candor) you should probably receive something akin to a Hash or some other data structure to be able to retrieve that information. If you read their documentation you'll do a lot better than someone telling you what to do who has never used any of those libraries.
You can't completely automate this process, the user must be involved to manually grant access to your application. That said, Temboo simplifies the OAuth process for GitHub by breaking it into two steps:
Generate an authorization URL that you can display to your user. This allows the user to authorize you to use their GitHub account. The first step also generates the callback URL you'll need for the second step of the process.
Retrieve an access token once the user has granted access to your application.
Full details on how Temboo simplifies GitHub OAuth (using PHP) can be found here.
(Full disclosure: I work at Temboo)

Categories