Posts tagged with laravel

My Google OAuth refresh token expires after one hour, even though both my OAuth and Google Ads API applications are verified and approved.

  • Both OAuth and Google Ads API apps are verified and approved.
  • Created a new client_credentials.json file after approval.
  • Using the provided Laravel example for the PHP Google Ads API.
  • Added the developer token with basic access and populated clientId and clientSecret in the google_ads_php.ini file.

For the refresh token i used command ~/go/bin/oauth2l fetch --credentials CLIENT_SECRET.json --scope adwords to obtain a refresh token. And added this token to google_ads_php.ini too.

Despite these steps, I consistently encounter a "token has been expired or revoked" error after 60 minutes.

enter image description hereI am learning web programming. I am working on adding whatsapp webhook to my web app. My understanding: In my web app, i implemented sending a whatsapp message template programmatically. When a client replies, i want to be able to receive and reply to the client. I followed the tutorial on https://business.whatsapp.com/blog/how-to-use-webhooks-from-whatsapp-business-api in combination with the tutorial in https://developers.facebook.com/docs/whatsapp/cloud-api/guides/set-up-webhooks#sample-app-endpoints.

My endpoint has be verifyed usefully. But when i send test message, i do not receive any message in my database. I was expecting the when i send test message/when client sends whatsapp message, which show successful, i should receive it in database.

whatsappcontroller.php

public function handleWebhook(Request $request){         $body = json_decode($request->getContent(), true);         if ($body['field'] !== 'messages') {             // not from the messages webhook so don't process             return response()->json([], 400);         }         foreach ($body['value']['messages'] as $message) {             $review = new Whatsapp();             $review->phonenumber = $message['from'];             $review->review = $message['text']['body'];             $review->save();         } 

Route.php

Route::post('/webhooks', [whatsappController::class, 'handleWebhook']); 

What am I not doing good or what do i need to understand about webhook. Because i am expecting that when messages are saved in database, then i can now use a get request url to get all the messages in my web page. Or is this not possible?

enter image description here

This is what the google ads team sent me when i tried running my ads. " Investigation:

Post consulting with the wider team, we found that the site has been disabled because we can still find a bad link in the latest system scan.

Below is the link that we’ve detected:

‘amam-zlon[.]com’ " because of which my website has been marked as malicious website.

Guys i have been working on this project past a really long time and when everything got set finally this is what i got from google i tried checking my c pannel scanning each file one by one but after 2 days of tireless scannin i still just got to 10% of the files. How to fix this problem please help me..

I am trying to replicate the Google Ads API Laravel Sample app and port it to a Laravel Jetstream application.

I keep getting the following error: Target class [GoogleAdsApiController] does not exist.

GoogleAdsApiController

<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use Google\Ads\GoogleAds\Lib\V15\GoogleAdsClient; use Google\Ads\GoogleAds\Util\FieldMasks; use Google\Ads\GoogleAds\Util\V15\ResourceNames; use Google\Ads\GoogleAds\V15\Enums\CampaignStatusEnum\CampaignStatus; use Google\Ads\GoogleAds\V15\Resources\Campaign; use Google\Ads\GoogleAds\V15\Services\CampaignOperation; use Google\Ads\GoogleAds\V15\Services\GoogleAdsRow; use Illuminate\Pagination\LengthAwarePaginator; use Illuminate\View\View; class GoogleAdsApiController extends Controller{     private const REPORT_TYPE_TO_DEFAULT_SELECTED_FIELDS = [         'campaign' => ['campaign.id', 'campaign.name', 'campaign.status'],         'customer' => ['customer.id']     ];     private const RESULTS_LIMIT = 100;  ... 

Routes/Web.php

<?php use Illuminate\Support\Facades\Route; use App\Http\Controllers\GoogleAdsApiController; Route::middleware([     'auth:sanctum',     config('jetstream.auth_session'),     'verified', ])->group(function () {     Route::get('/dashboard', function () {         return view('dashboard');     })->name('dashboard'); }); Route::post(     'pause-campaign',     'GoogleAdsApiController@pauseCampaignAction' ); Route::match(     ['get', 'post'],     'show-report',     'GoogleAdsApiController@showReportAction' );  Route::get('/', function () {     return view('welcome'); }); Route::get('/main', function () {     return view('main'); }); 

Any help is much appreciated

I'm trying to use the API to send to myself a custom message, I can already send a hello world template, but I been unable to send myself a custom only text message.

//API token given by Meta         $token = '*private*';         //Reciever number of msg         $telefono = '*private*';         //URL of msg given by Meta         $url = '*I think is private too*';         $mensaje = '{"messaging_product": "whatsapp", "to": "'.$telefono.'", "type": "text", "text": {"preview_url": false, "body": "MESSAGE_CONTENT" }}'; //header of msg $header = array("Authorization: Bearer " . $token, "Content-Type: application/json"); 

so that's what I use to make the Curl to send the message, which I do like this

//curl init         $curl = curl_init();         curl_setopt($curl, CURLOPT_URL, $url);         curl_setopt($curl, CURLOPT_POSTFIELDS, $mensaje);         curl_setopt($curl, CURLOPT_HTTPHEADER, $header);         curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);         //get response from information sent         $response = json_decode(curl_exec($curl),true);         //print response         print_r($response);         //get curl response code         $status_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);         print_r($status_code);         //close curl         curl_close($curl); 

I think is kind of working, because it shows on screen this result

Array ( [messaging_product] => whatsapp [contacts] => Array ( [0] => Array ( [input] => phone [wa_id] => 56994134989 ) ) [messages] => Array ( [0] => Array ( [id] => i think is private too ) ) ) 200

In the end I just need to test if its possible to send myself custom text messages, the thing is that this code isn't working as I want it to, as you should see, on the print of the result and the status_code, the code is 200 what makes me think that the request is going through at some point but maybe it need something else to finally be sent to my phone.