I am making a post request to the tiktok API, entering the 3 parameters that are requested, but when I carry out the request, it shows me the following: "Required fields are missing: app_id is required.", I attach an image:
but when performing the same procedure in postman if I have a positive response.
here is my code:
my route:
Route::get('callback-tiktok', [AuthsController::class, 'SocialAuth']);
my controller:
<?php
namespace AppHttpControllers;
use IlluminateHttpRequest;
use GuzzleHttpClient;
use GuzzleHttpExceptionClientException;
class AuthsController extends Controller
{
public function SocialAuth(Request $request)
{
$a = $request->input('auth_code');
// create a guzzle client object here
$client = new Client();
$respuesta = $this->client->request(
'POST',
'https://business-api.tiktok.com/open_api/v1.3/oauth2/access_token/',
[
'form_params' => [
'app_id' => '7112335319877287937',
'secret' => '18f52730856f43ed821187bfa9283794ca360ef1',
'auth_code' => $a
],
'headers' => [
'Content-Type' => 'application /json'
],
]
);
return response()->json($respuesta->getBody()->getContents());
}
}
When compiling I get the following:
The stream or file "/home/epgutp/tiktok/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/home/epgutp/tiktok/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/home/epgutp/tiktok/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/home/epgutp/tiktok/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/home/epgutp/tiktok/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/home/epgutp/tiktok/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file….
2
Answers
Well, maybe this can help someone, solution to my question:
In this case use the Http facade:
Response to my request:
I guess, you made some couple of errors, try this:
Applying this solution gives me the following error: