Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Laravel : Attempt to read property "body" on bool #104

Open
RouxCool opened this issue Sep 11, 2023 · 2 comments
Open

Laravel : Attempt to read property "body" on bool #104

RouxCool opened this issue Sep 11, 2023 · 2 comments

Comments

@RouxCool
Copy link

Version Laravel : 8.83.27
Version PHP : 8.2.8


1° Pourquoi j'ai toujours cette erreur lors de l'envoie d'SMS ?

Code :

	public function test_global()
	{
		// Construct transport and client
		$transport = new SocketTransport(array('gra.smpp.ovh'),2776);
		$transport->setRecvTimeout(10000);
		$smpp = new SmppClient($transport);
		$tags = [];

		// Activate binary hex-output of server interaction
		$smpp->debug = true;
		$transport->debug = true;

		// Open the connection
		$transport->open();
		$smpp->bindTransmitter(env('SMPP_LOGIN'),env('SMPP_PASSWORD'));

		// Prepare message
		$message = 'H€llo world';
		$encodedMessage = GsmEncoder::utf8_to_gsm0338($message);
		$from = new SmppAddress(env('SMPP_SENDER'),SMPP::TON_ALPHANUMERIC);
		$to = new SmppAddress(33712345678,SMPP::TON_INTERNATIONAL,SMPP::NPI_E164);

		// Send
		$smpp->sendSMS($from,$to,$encodedMessage,$tags);

		// Close connection
		$smpp->close();
	}

Erreur :

• Tests\Feature\MasterTest > global
 PHPUnit\Framework\ExceptionWrapper 

Attempt to read property "body" on bool

at vendor/its/php-smpp/src/OnlineCity/SMPP/SmppClient.php:400
  396▕                        }
  397▕                }
  398▕ 
  399▕                $response=$this->sendCommand(SMPP::SUBMIT_SM,$pdu);
➜ 400▕                $body = unpack("a*msgid",$response->body);
  401▕                return $body['msgid'];
  402▕        }
  403▕ 
  404▕        /**
@sairmali
Copy link

1+

@p5yk0
Copy link

p5yk0 commented Mar 29, 2024

Librairie pas compatible avec php8.

Depuis php8 les sockets ne sont plus une ressource mais un objet de type Socket.

Pour patcher faut modifier la fonction isOpen de sockettransport.class.php

public function isOpen()
{
   if ( !(is_resource($this->socket) || $this->socket instanceof \Socket) ) return false;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants