Getting error:invalid_grant in Salesforce for grant type authorization_code if giving authorization from another org

I am having issue on granting authorization for user that is outside of my app’s org.

here is the http post request I am trying to make, I am using authorization_code so I can get refresh token as I need it.

$response = $client->post($tokenUrl, [
 'form_params' => [
  'grant_type' => 'authorization_code',
  'client_id' => $clientId,
  'client_secret' => $clientSecret,
  'redirect_uri' => $redirectUri,
  'code' => $authorizationCode,
 ],
]);

I am not sure if I’m missing something on my salesforce set up, below are screenshots:

Screenshot of Oauth Settings 1

Screenshot of Oauth Settings 2

Oauth Policy Settings

Here is a screenshot of granting permission

Permission Grant

The error I got

{“error”:”invalid_grant”,”error_description”:”authentication failure”}

I want to successfully grant any org to access my connected app

PHP-DI invalid definition exception, factory is neither a callable nor a valid container entry

I am trying to use php-di in a project for creating a renderer that renders my default views.

This is how my index.php looks like :

<?php
require "../vendor/autoload.php";
use DIContainerBuilder;
use FrameworkRendererRendererInterface;
use FrameworkRendererTwigRendererFactory;
use function DIfactory;

$builder= new ContainerBuilder();
$builder->addDefinitions([
    RendererInterface::class => factory(TwigRendererFactory::class),
    'views.path'=> dirname(__DIR__) . '/views'
]);
$container= $builder->build();
$renderer= $container->get(RendererInterface::class);//<-- Line causing the error
var_dump($renderer);
die();

My TwigRenderFactory looks like this :

<?php
namespace FrameworkRenderer;
use PsrContainerContainerInterface;
class TwigRendererFactory
{
    public function __invoke(ContainerInterface $container)
    {
        return new TwigRenderer($container->get('views.path'));
    }
}

My directory hierarchy is like this :

+---public
|   |   index.php
+---src
|   +---Blog
|   |   |   BlogModule.php
|   |   ---views
|   |           index.php
|   |           index.twig
|   |           show.php
|   |           show.twig
|   ---Framework
|       |   App.php
|       |   Router.php
|       |   TwigRendererFactory.php
|       +---Renderer
|       |       PHPRenderer.php
|       |       RendererInterface.php
|       |       TwigRenderer.php
|       ---Router
|               Route.php
+---vendor   
---views
        footer.php
        header.php
        layout.twig
    

And I have my autoload set in my composer.json like this :

"autoload": {
    "psr-4": {
        "Framework\": "src/Framework",
        "App\": "src",
        "Tests\": "tests"
    }
},

With this setup I get this exception from php-di :

Fatal error: Uncaught DIDefinitionExceptionInvalidDefinition:
Entry "FrameworkRendererRendererInterface" cannot be resolved:
factory 'Framework\Renderer\TwigRendererFactory' is neither a callable nor a valid container entry in E:____MQBAKAPOO-pratiquevendorphp-diphp-disrcDefinitionResolverFactoryResolver.php:91
Stack trace:
#0 E:____MQBAKAPOO-pratiquevendorphp-diphp-disrcDefinitionResolverResolverDispatcher.php(71): DIDefinitionResolverFactoryResolver->resolve(Object(DIDefinitionFactoryDefinition), Array)
#1 E:____MQBAKAPOO-pratiquevendorphp-diphp-disrcContainer.php(390): DIDefinitionResolverResolverDispatcher->resolve(Object(DIDefinitionFactoryDefinition), Array)
#2 E:____MQBAKAPOO-pratiquevendorphp-diphp-disrcContainer.php(139): DIContainer->resolveDefinition(Object(DIDefinitionFactoryDefinition))
#3 E:____MQBAKAPOO-pratiquepublicindex.php(23): DIContainer->get('Framework\Rende...')
#4 {main} thrown in E:____MQBAKAPOO-pratiquevendorphp-diphp-disrcDefinitionResolverFactoryResolver.php on line 91

I’ve double-checked everything that I could, I tried to put an echo inside the __invoke() method of the TwigRendererFactory class but it seems the __invoke() method is never called for some reason so I don’t know what to do.

xdebug not installed on php 8.3 docker container

I’m using this Dockerfile

FROM php:8.3-apache

RUN pecl install xdebug-3.3.2 && docker-php-ext-enable xdebug

RUN apt-get update && apt-get install -y 
    libfreetype6-dev 
    libjpeg62-turbo-dev 
    libpng-dev 
    libzip-dev 
    zip 
    && docker-php-ext-configure gd --with-freetype --with-jpeg 
    && docker-php-ext-install -j$(nproc) gd pdo pdo_mysql zip

RUN echo "xdebug.mode=debug" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.start_with_request=yes" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.client_host=host.docker.internal" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini

RUN a2enmod rewrite

EXPOSE 9003

WORKDIR /var/www/html

COPY apache-config.conf /etc/apache2/sites-available/000-default.conf

COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer

CMD ["apache2-foreground"]

when I check phpinfo() I see that xdebug is no t installed, the same Dockerfile with

FROM php:8.1-apache

RUN pecl install xdebug-3.1.1 && docker-php-ext-enable xdebug

works with no problems

I checked on xdebug web and xdebug 3.3.2 is compatible with php 8.3

In the group chat, my bot always forces me to reply every time I launch Telegram

I’ve made a simple Telegram bot that invites a user to a Trello board and notifies all users in the group chat when a card is moved from one list to another. I’m facing a problem. Every time I launch Telegram and select the group chat, I get this. In a private chat between me and the bot, everything is fine.

This is the GitHub repo of my project: https://github.com/loglinn05/loglinn05_chatos_bot/

To handle webhook requests from Telegram, I use defstudio/telegraph. This is what my handler class looks like:

<?php

namespace AppTelegram;

use AppModelsUser;
use DefStudioTelegraphEnumsChatActions;
use DefStudioTelegraphHandlersWebhookHandler;
use GuzzleHttpClient;

class Handler extends WebhookHandler
{
  private $trelloApiBaseUrl;
  private $trelloApiKey;
  private $trelloApiToken;
  private $boardId;

  public function __construct()
  {
    $this->trelloApiBaseUrl = env("TRELLO_API_BASE_URL");
    $this->trelloApiKey = env("TRELLO_API_KEY");
    $this->trelloApiToken = env("TRELLO_API_TOKEN");
    $this->boardId = env("BOARD_ID");
  }

  public function start()
  {
    $from = $this->message->from();
    $fromUser = User::where('telegram_user_id', $from->id())->first();

    $this->chat->action(ChatActions::TYPING)->send();

    // saying hello
    $name = $from->firstName();
    $this->reply("Hi, $name!");

    // adding a user to the database if they're not there
    if (!$fromUser) {
      $user = new User();
      $user->telegram_user_id = $from->id();
      $user->first_name = $from->firstName();

      if ($from->lastName()) {
        $user->last_name = $from->lastName();
      }

      $user->telegram_username = $from->username();
      $user->save();

      if ($user) {
        $this->chat->action(ChatActions::TYPING)->send();
        $this->reply("You've been added to the database.");
      }
    }

    $this->chat->action(ChatActions::TYPING)->send();
    $this->reply("If you need further assistance, enter /help.");
  }

  public function help()
  {
    $this->chat->action(ChatActions::TYPING)->send();
    $this->reply("
      I can invite you to our Trello board. Let's work _together_! xE2x9CxA8
      n*Enter /invite to proceed.*
    ");
  }

  public function invite()
  {
    $from = $this->message->from();
    $fromUser = User::where('telegram_user_id', $from->id())->first();

    $fromUser->status = "providing email";
    $fromUser->save();
    $this->forceToEnterEmail();
  }

  public function handleUnknownCommand(IlluminateSupportStringable $text): void
  {
    $this->chat->action(ChatActions::TYPING)->send();
    $this->reply("What do you mean?
    nI don't know this command! xF0x9Fx98x85");
  }

  public function handleChatMessage($email): void
  {
    $from = $this->message->from();
    $fromUser = User::where('telegram_user_id', $from->id())->first();

    if ($fromUser->status == "providing email") {
      $fullName = [];

      // set the user's email if it's not set
      // and set the full name for the invitation request
      if ($fromUser) {
        $fullName = ['fullName' => "{$fromUser->first_name} {$fromUser->last_name}"];
      }

      $invitationResponse = $this->sendInvitationRequest($email, $fullName);

      if (
        $invitationResponse->getStatusCode() == 200
      ) {
        if (!$fromUser->email) {
          $fromUser->email = $email;
          $fromUser->save();
        }
        $this->onSuccessfulInvitation();
      } elseif (
        $invitationResponse->getBody() == 'Member already invited'
      ) {
        $this->clearFromUserStatus();

        $this->chat->action(ChatActions::TYPING)->send();
        $this->reply("You're already invited. Enjoy the experience!");

        $this->getLinkToTheBoard();
      } elseif (
        json_decode($invitationResponse->getBody())->message == "invalid email address"
      ) {
        $this->chat->action(ChatActions::TYPING)->send();
        $this->reply("Invalid email address.");

        $this->forceToEnterEmail();
      } else {
        $this->clearFromUserStatus();

        $this->chat->action(ChatActions::TYPING)->send();
        $this->reply("Unknown error occurred during invitation attempt.");
      }
    }
  }

  private function forceToEnterEmail()
  {
    $this->chat->action(ChatActions::TYPING)->send();
    $this->chat->message("Please, enter your email so I can invite you:")->forceReply("Enter your email here...", selective: true)->send();
  }

  private function sendInvitationRequest($email, $fullName)
  {
    $client = new Client();
    $invitationResponse = $client->put(
      "$this->trelloApiBaseUrl/boards/$this->boardId/members?email=$email&key=$this->trelloApiKey&token=$this->trelloApiToken",
      [
        'http_errors' => false,
        'json' => $fullName
      ]
    );
    return $invitationResponse;
  }

  private function clearFromUserStatus()
  {
    $from = $this->message->from();
    $fromUser = User::where('telegram_user_id', $from->id())->first();

    $fromUser->status = null;
    $fromUser->save();
  }

  private function onSuccessfulInvitation()
  {
    $this->clearFromUserStatus();

    $this->chat->action(ChatActions::TYPING)->send();
    $this->reply("You've been successfully invited.");
    $this->getLinkToTheBoard();
  }

  private function getLinkToTheBoard()
  {
    $client = new Client();

    $getBoardResponse = $client->get("$this->trelloApiBaseUrl/boards/$this->boardId?key=$this->trelloApiKey&token=$this->trelloApiToken");

    if ($getBoardResponse->getStatusCode() == 200) {
      $linkToTheBoard = json_decode($getBoardResponse->getBody())->url;

      $this->chat->action(ChatActions::TYPING)->send();
      $this->reply("Here's the link to the board:
      n$linkToTheBoard");
    } else {
      $this->chat->action(ChatActions::TYPING)->send();
      $this->reply("Unfortunately, we couldn't get the link to the board.");
    }
  }
}

As you can see, the selective field is set to true:

private function forceToEnterEmail()
{
  $this->chat->action(ChatActions::TYPING)->send();
  $this->chat->message("Please, enter your email so I can invite you:")->forceReply("Enter your email here...", selective: true)->send();
}

But the bot still forces a user to enter their email.

So I decided to write something to the log in this function. And I noticed that nothing was added into the log file when I started Telegram again. In a PowerShell terminal where ngrok was running, I didn’t notice any requests to the Telegram API when the app launches.

If you have any ideas on how to solve this issue, please, share them. I’ll appreciate any help.

If you need something else to understand my question, feel free to ask.

Create an image to specific size and fill any space with black infill in PHP

Looking to resize images to set dimensions of (1080×1350) without cropping, just fill the dead space with black boarders/buffers.

As we can’t control what size and aspect ratios users uploads images. Im looking to create a php function that creates a ‘canvas’ that has set dimensions of 1080×1350.

I then place the users image in the middle this ‘canvas’ (without cropping) and fill any dead space with black boards.

Here’s what I’ve developed so far:

// orignal image size
$width = imageSX($image);
$height = imageSY($image);


// canvas size
$thumb_width = 1080;
$thumb_height = 1350;


$original_aspect = $width / $height;
$thumb_aspect = $thumb_width / $thumb_height;
        
if ( $original_aspect >= $thumb_aspect ) {
    $new_height = $thumb_height;
    $new_width = $width / ($height / $thumb_height);
} else {
    $new_width = $thumb_width;
    $new_height = $height / ($width / $thumb_width);
}
        
$tmp = imagecreatetruecolor( $thumb_width, $thumb_height );
imagealphablending($tmp, false);
imagesavealpha($tmp, true);
        
$transparent = imagecolorallocatealpha($tmp, 255, 255, 255, 127);
imagefilledrectangle($tmp, 0, 0, round($new_width), round($new_height), $transparent);
        
                
// Resize and crop
imagecopyresampled($tmp, $image, round(0 - ($new_width - $thumb_width) / 2), round(0 - ($new_height - $thumb_height) / 2), 0, 0, round($new_width), round($new_height), round($width), round($height));


what changes would I need to achieve the expected results. I think i’m close, but just would like to bounce some ideas around.
Thank you.

trouble sending post request with to laravel end point for razorpay order ceration

when i send a get request here every thing works perfectly fine but post request gives me errors
react method for sending to payment.razorpay route

`const handlePayment = ()=>{
localStorage.setItem(‘selectedSeats’, selectedSeats);

axios.post(route('seats.checkAvailability'), { selectedSeats })
.then(response => {
  console.log('Success:', response.data);
  try{
      axios.post(route('payment.razorpay'), {
        selectedSeats,
        totalAmount: total,
        user: auth.user
      },
      {headers:{"Content-Type" : "application/json"}}
    );
  } catch (error) {
    console.error(error.response.data);
  }
})
.catch(error => {
  console.log('in catch');
  setErr(error.response.data.error);
});

};`

here is the route
Route::post('/razorpay', [PaymentController::class, 'processPayment'])->middleware(['auth'])->name('payment.razorpay');

function in PaymentController
` public function processPayment( Request $request)
{

    dd('here');

    $request->validate([
        'selectedSeats' => 'required|array',
        'total' => 'required|numeric|min:0',
        '$user' => 'required'
    ]);

    $selectedSeats = $request->input('selectedSeats');
    $totalAmount = $request->input('total'); 
    $user = $request->user();

    $api_key = config('services.razorpay.razorpay_key');
    $api_secret = config('services.razorpay.razorpay_secret');
    $api = new Api($api_key, $api_secret);
    
    try {
    $order = $api->order->create([
        'amount' => $totalAmount * 100,
        'currency' => 'INR',
        'receipt' => 'order_receipt_id_123',
        'payment_capture' => 1 // Auto capture payment
    ]);
    } catch (Exception $e) {
        return response()->json(['status' => 'error', 'message' => 'Failed to create Razorpay order'], 500);
    }

    $data = [
        "key"  => $api_key, 
        "amount" => $order['amount'], // In paise
        "currency" => $order['currency'],
        "name" => $user->name,
        "description" => "Ticket Purchase",
        "image" => "https://cdn.razorpay.com/logos/GhRQcyean79PqE_medium.png",
        "prefill" => [
            "name" => $user->name,
            "email" => $user->email
        ],
        "theme" => [
            "color"  => "#3399cc"
        ],
        "order_id" => $order['id'], // Pass the order ID from Razorpay
    ];

    return Inertia::render('Checkout', [
        'data' => $data, // No need to json_encode here, Inertia will handle it
        'selectedSeats' => $selectedSeats, // Pass selected seats to the view
        'totalAmount' => $totalAmount, // Pass the total amount
    ]);
}`

i tried adding a dd() at the start of the function but the request wont even reach there
i also tried using Inertia.post

should i keep this as a get route cause it works perfectly fine, if yes where should i pass the data ?

Issues After Upgrading Laravel from 7 to 11 and Passport from 9 to 12

I have upgraded Passport from version 7 to 12 and uploaded my files to the server, which is now running Laravel 11. I’m wondering if the existing customers’ access tokens and refresh tokens will remain valid or if they will become invalid after the upgrade. In the case that the tokens do become invalid, what steps should I take to resolve this issue and ensure that customers can continue accessing their accounts seamlessly?

Shgow WooCommerce Total price With & Without VAT Tax on Checkout

In WooCommerce I need to show the price inclusive VAT and without VAT. The price is including VAT. On checkout and cart, the price is show including VAT.

Below the total price (including VAT), I need a line with the price exclusive VAT. Preferable with the amount of VAT which is charged.

I cannot see how to do this.
Does anyone has an idea?

PHP auction in real-time

I’m going to create an auction (online) in PHP accessible from multiple clients to increase the offer value. To do this I created 2 web pages:

  1. dashboard.php – show the item with an offer and count down – if time expires the system assigns the item to the last user
  2. offer.php – any clients (after logging) can update the offer in dashboard.php

Result: I want to show the auction in real-time in a dashboard for all users and all participants can increase offers via tablet or mobile phone by using a button.

How can I refresh the dashboard after a client posts a request to increase the offer? Could you suggest a solution?

How can i resolve Dynamic pages issue in my shopify website

I’ve noticed that over the past two months, Google has been indexing multiple versions of my main collection page. For example, my main page is example.com/collection/kitchen-tile, but Google is also indexing similar pages like example.com/collection/kitchen-tile?dfhpage1, example.com/collection/kitchen-tile?dfhpage2, and so on. Why is this happening, how can I fix it, and is it harmful to my SEO ranking?

How can I resolve this issue

WP Rocket’s slow caching speed

The plugin documentation states that the number of cached pages per minute can be dynamic and depends on a large number of factors. However, some studies have shown that on average this can be around 45 pages per minute. On my website, the plugin caches approximately 4-6 pages per minute, and considering that the site has around 1,500 pages, the entire cache is completed in about 4 hours. The question is:

  • What factors influence the speed of page caching?
  • What are the ways to speed up cache creation? Especially for websites with 5-10 thousand pages. And how can this be done smoothly, without creating a high load on the server?

I tried adjusting the plugin settings and increasing the caching interval to see if it would improve the caching speed. However, the improvement was minimal, and it still took several hours to cache all pages. I expected the process to be faster, especially for a website with around 1,500 pages, but the performance remains slow

not able call sweetalert from PHP function

I try to integrate sweetalert in my PHP function to show session status,but sweet alert is not working.please help me on this.

function alertmessage()
{
    if(isset($_SESSION['status']) && $_SESSION['status'] !='')
{
  ?>
  <script>
  swal.fire({
    text: "<?=$_SESSION['status']?>",
    icon: "<?=$_SESSION['status_code']?>",
    confirmButtonColor: "#008B8B",
    confirmButtonText: "Ok!",
    showClass: {
    popup: `
      animate__animated
      animate__fadeInUp
      animate__faster
    `
  },
  hideClass: {
    popup: `
      animate__animated
      animate__fadeOutDown
      animate__faster
    `
  }
  });
  </script>
  <?php
        
        unset($_SESSION['status']);
    }
}

i called the function in required page as
<?= alertmessage() ?>

it showing session status message if i didnt add sweetalert.

Firestore is not returning any collection data in Laravel

The problem is that Firestore is not returning any collection data in Laravel. I am using the google/cloud-firestore package for this.

 public function __construct(LoggerInterface $logger)
    {
        $this->firestoreDB = app('firebase.firestore')->database();
        $docRef = $this->firestoreDB->collection('user')->document('7UUnkB6sSZgrBYazpmRlpCHJMZm2');
        $snapshot = $docRef->snapshot();
        if ($snapshot->exists()) {
            printf('Document data:' . PHP_EOL);
            print_r($snapshot->data());
        } else {
            printf('Document %s does not exist!' . PHP_EOL, $snapshot->id());
        }
        die;
        $this->logger = $logger;
    }


OR
 public function __construct(LoggerInterface $logger)
    {
        $this->firestoreDB = app('firebase.firestore')->database();
        $docs = $this->firestoreDB->collection('user')->documents();
        dd($docs);
    }


I want like print all document in collection and data for specific document.enter image description here[enter image description here]

Upload profile video, instead of profile photo [closed]

I am trying to upload a MP4 file instead of a image file jpg,gif.

I tried changing the function in the thumb nail creation from image extensions to video MP4 extensions, which never work, as the thumb nail GD function don’t support video files.

I modified the gd function to get the upload MP4 file to the folder where the profile updates is stored, with it original file name, Instead of the unique id name meant to bind to the actual file,

It also never update the database

I think it something to do with the GD support function, but how could I do it without this function, and bind file instead of binding the thumbnail.

Profile photo

I am basically trying to use MP4 instead!! Please check the above