Uploading a video through youtube official library through php cli request but resulting in (Undefined Index: HTTP_HOST). Any idea to solve this? - google-api

I'm getting an error of Undefined Index: HTTP_HOST while trying to send a video to Youtube API using the Official Youtube Google API PHP Library.
The request is happening under laravel scheduler to run cli request to do the task.
I have tried and find a way of adding Host Header Parameter to the request but couldn't get it done.
I also tried specifying the rootUrl param when iniatializing the Google Youtube Service like so;
$service = new GoogleServiceYoutube($client, 'https://youtube.googleapi.com');
What can I do to solve this error?

Related

How to send a file using API

I am trying to upload a file using API to an app. However, it does not work and returns a timeout error.

API server block request from GuzzleHttp

I have 2 servers which are API server and Client server ....
Both server using Google Cloud server and I use Laravel framework to develop my system...
So, currently the problem is, it return 403 error when calling API (to API server) using GuzzleHttp (from Client Server).....
But after I change the user agent to curl/7.65.3, suddenly it is working fine...
But I want to know why??? Is there any other solution without changing the user-agent???
Thanks
What is your use method? If GET you can refer to:
GET Requests That Include a Body
If a viewer GET request includes a body, CloudFront returns an HTTP status code 403 (Forbidden) to the viewer.
https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/RequestAndResponseBehaviorCustomOrigin.html

Upload vimeo video with Laravel 8.x

I am testing vimeo with vimeo basic account and Laravel 8.x / guzzle in order to pay for a pro licence.
I am trying to implement a form-based video upload approch. According to the documents available to vimeo website, the first step consists in sending a post request to /me/videos then i will receive a response that will contain an HTML form in the upload.form field. Yet, the request status code is correct (201 : created).
My issue is that i don't see this field (upload.form) in the api server response (i have made a dd($response)).
Here is the code in my controller:
$response = Http::withToken('xxxxxxx')->withHeaders([
'Content-Type'=>'application/json',
'Accept'=>'application/vnd.vimeo.*+json;version=3.4'
])->post('https://api.vimeo.com/me/videos', [
'upload'=>[
'size'=>$request->file->getsize(),
'approch'=>'post',
]
]);
Can a person help me solve this problem?
The link of the documentation i have read is: Working with Video Uploads and other API references.
I really need your help please
Thank you for all.
I have tried the same request with postman and it has allowed me to understand that the instruction dd($response) does not give me all the informations contained in the server's response but just some informations in the headers.
To see what i wanted i have used one of these instructions:
dd($response->body());
// or
dd($response->json())
For example to obtain the HTML form provided by vimeo API, i have to use this instruction:
$response->json()['upload']['form'];
So i consider closed, this ticket.

accessNotConfigured error (403) from Youtube API via google-api-php-client

I've followed all the steps and can use the api console to create event and edit event, but I'm unable to programmatically get same to work from my code, using the API PHP library from Google.
The error I get is: "domain": "usageLimits", "reason": "accessNotConfigured", "message": "Access Not Configured. YouTube Data API has not been used in project......."
Anyone else had any similar experiences with the API and any success getting past this?
I had a similar issue and resolved it by starting from scratch and creating a new project, then creating an API key on the new project. Everything worked fine then!

how to import google contacts in laravel 5.2

I'm working with laravel and I have done login with Google in laravel using socialite. Now I'm trying to get google contacts and I'm using Artdarek\OAuth for this. But I'm getting an error
TokenResponseException in StreamClient.php line 68: Failed to request resource. HTTP Code: HTTP/1.1 400 Bad Request
here is error screen shot
I also tried many links, but I don’t know what’s problem with my code.

Resources