Skip to content

Instantly share code, notes, and snippets.

@tim-cotten
Last active March 5, 2021 02:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tim-cotten/b009e854ea34afa5f9891113588872a8 to your computer and use it in GitHub Desktop.
Save tim-cotten/b009e854ea34afa5f9891113588872a8 to your computer and use it in GitHub Desktop.
PHP Bugs: Confusing Non-Objects for Objects (Example F)
<?php
function exchange_send_message_raw($context, $content)
{
$location = "https://test.cotten.io/exchange/raw_message.php";
$request = array('direction' => 1, // outgoing
'context' => $context,
'content' => json_encode($content));
$response = ProxyPostClient::request($location, $request);
$response_obj = json_decode($response);
if (!empty($response_obj) && isset($response_obj->content)) {
print_formatted_log("Exchange Response: Success");
print_formatted_log(json_encode($response_obj));
echo "\n";
} else {
print_formatted_log("Exchange Response: Error");
print_formatted_log(json_encode($response_obj));
print_formatted_log($response); // raw text response
echo "\n";
}
return $response_obj->content;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment