Internal Server Error when using YouTube API & PHP - php

After months of putting it off I am trying to update my code to use Version 3 of the YouTube Data API.
I am in China so I need to use a VPN to work on this code, but the servers are in Atlanta. The line of code that gives me grief is:
$this->youtubeService = new Google_YoutubeService($this->googleClient);
That actual Google Client creates fine I can print it to the screen. I have blown away the API on the server thinking something went wrong in the upload, the example code using Books runs, I've enable the API in my console, I put printf's on either side of my code and narrowed it down to this line, but all I know is
[Error] Failed to load resource: the server responded with a status of 500 (Internal Server Error) (favouriteQuotationsMashup.php, line 0)
I can comment the line out to keep my code and my site running, but I am really not amused that I keep having to jump through hoops to get APIs to work again, YouTube is cool and all but it isn't vital to the function of my website, the only place I use it is in my quotation mashup. How do I figure out what is causing this error, especially if it is in Google's now giant beta PHP library?

Related

503 in php file when making an API Call

I am having trouble with several php files.
The problem is when I try to access my WebApp in said php files it results in a 503 error. Both files have API calls to different services that have worked perfectly until yesterday. When I remove the API call from the code the WebApp opens with no problem. I called both API services and they are both getting the API requests made from my server with no problem.
I've already exhausted all options to fix this error but came up with no results.
Any help is valid.
Thank you so much.
I've tried to change PHP version, but as I said there is no problem with PHP. Removing the API call makes the webapp function normally.

Logging http error codes (500, 504) in telegram chat with bot

I have site that working with yii2 and nginx, send information from site pages to the chat in telegram with bot.
Sometimes site can't load page or have troubles with something else. The task is that bot need text to chat, have problem HTTP:CODE, I don't want to solve problems with loading pages, I talk about other.
On that moment bot can text if HTTP code error is 403, BUT, this method can't work with 500,504 error codes (Man who have big experience in this job, say, that isn't work, because php code will not run on these errors)
I can't give source code (closed repository) I didn't write this question if Google searching give results, only HTTP errors from telegram (account that send message in blacklist)
Thanks for help😤
UPD found how error 403 logging in this project https://www.yiiframework.com/doc/guide/2.0/en/runtime-logging and found same theme where text that error 500 logging in apache but in this project use nginx https://stackoverflow.com/questions/55023726/yii2-logging-500-errors-on-production/55062137

Maps API using file_get_contents causes internal 500 error

I have been using the Maps API service for a month now. This morning I found that the service has stopped working. Any request to maps.googleapis.com causes my server to hang for a moment and then display the internal server 500 error.
At first I thought I was blocked / banned by google and there must be something I have overlooked with the t and c's but having looked further there are no notifications in my google api dev console.
If I make a request from another server using the same API key it works.
If I make a request directly in the url bar with the same API key it also works.
It only hangs and causes a 500 error for the domain maps.googleapis.com and not any other. I am guessing that Google has blocked my server IP but it seems odd that they would do this and my API key still works fine. If they had blocked me it wouldn't it be the whole API account?
Firstly, how do I know if I am blocked?
Secondly, why do I not get a error from google saying what the issue is?
Why does it cause my server to issue a 500 error? If my server is blocked it wouldn't just respond to say whatever the API problem is?
All seem very strange to me. It only started today. I am hitting the API with file_get_contents using php 5.1 on an apache server.
To clarify, the 500 error is on my server, I cannot see any response from the http request because it hangs and then spits out the 500 error.
And now after 3 hours of debugging it works for no explained reason. The only possibility that i can think of is that the hosting company has been doing maintenance and something they changed caused this. after waiting on hold for 20 minuts they disconnected but perhaps they looked into it behind the scenes for me. Pretty annoyed a whole morning waisted and although im happy it has resolved its still frustrating to not know what or why

Gracenote php throwing HTTP RESPONSE ERROR

I'm trying to get Gracenote APi to work on my site. I got it working some months back but never went any further. I am using the same credintials that used back then when it worked and the php gracnote class from Rich Adams on github. I am trying to get the example file to work but am recieving this error.
Fatal error: Undefined class constant 'HTTP_RESPONSE_ERROR' in C:\wamp\www\Interface\php-gracenote-master\php-gracenote\HTTP.class.php on line 113
This is on my localhost atm. I tried it on my server aswell and it threw the same error.
I have made another app on Gracenote thinking they may have blocked the old one but that didn't help. Does gracenote block the entire account if it isn't active for some months or I am I just been a tool and missing something here?
EDIT
The issue seems to be when trying to register for a user id
This is caused when cURL returns an error code when trying to make the request to Gracenote's servers.
There was a bug in php-gracenote where HTTP_RESPONSE_ERROR wasn't defined, which is why you didn't get a human-friendly error message. I've just updated the code on GitHub, so you'll actually get a proper error now.
The exception will give you the cURL error code that was returned, which you can lookup in the libcurl error codes to see what the problem is. Could be anything from a DNS issue to an incorrect SSL version.
As far as I'm aware, Gracenote doesn't deactivate accounts for inactivity on the developer program. This may change in future though.

OAuth 2.0 and Amazon Beanstalk

I'm relatively new to programming and am having trouble with using OAuth with my app hosted on Amazon Beanstalk.
What I wish my app to do is to connect to the Constant Contact API, using the base code shown here
https://github.com/shannon7wallace/OAuth-2-PHP-Example
If I execute this code locally, everything works fine. I am able to login with my constant contact credentials and pull data. I was sure to setup my redirect uri in my constant contact developer key correctly, and everything works perfectly locally.
When I deployed it to AWS however, I would get a blank page when trying to navigate to index.php. I double checked my container settings and the zip package I uploaded to ensure I was pointing to the correct directories, and made sure my AWS healthcheck pointed to a publicly accessible URL (AWS shows app as being healthy), but the page is blank.
If I replace my index.php with simply HTML or even phpinfo(), it works. I suspect it gets hung up at the authentication check but even if I hard code my account credentials in and remove the login logic, I still get a blank page. Even the html outside my php script tags does not display, regardless if I include things like or other head tags.
Googling for OAuth + Beanstalk produces very little, and the constantcontact API documentation, at least to my inexperienced eyes, is pretty sparse, but the closest thing I could find addressing my problem is this
https://forums.aws.amazon.com/thread.jspa?messageID=277339&#277339
The scenario in the above thread seems to address a problem much more specific than mine, and I am unsure on how to apply the solution to my particular case.
Is there something obvious I am missing? I can't believe AWS would be unsuited for apps using OAuth considering the vast array of projects that are hosted on it.
I appreciate any help anyone can offer.
The Beanstalk container options for PHP have an option to control whether errors should be displayed; switching it to "On" should write a fatal error on your page.
As it turns out, even after changing the setting, the pages would still be blank. I'm not sure if the feature is broken, but it definitely guards you from accidentally leaving it on :)
You'd have to log into your instance (assuming your site isn't loaded yet and it's really just one) and edit your code to insert the customary debug statements as high up as possible:
error_reporting(-1);
ini_set('display_errors', 'On');
Barring any parse errors in your page, it will show the offending error.

Categories