Skip to content

Commit 232cb47

Browse files
Pull request #25: Feature/EOA-5903 SS Intellegence
Merge in SDK/php_telesign from feature/EOA-5903-SS-Intellegence to developer Squashed commit of the following: commit 4b2de55a789441090168e0a23f4992a70ce255c5 Merge: 7a95ab1 b7c3190 Author: Juan Camilo Martinez <jmartinez@telesign.com> Date: Thu Jan 15 10:43:39 2026 -0500 Solve issues merge commit 7a95ab10cb538f530060d80207f5730dd0c4523e Author: MousumiMohanty <@telesign.com> Date: Thu Oct 23 16:09:37 2025 +0530 update the release file commit 94efe5beb37d9d7eca4fc91bd118362891c74cf6 Author: MousumiMohanty <@telesign.com> Date: Thu Oct 23 13:36:03 2025 +0530 Added support for Intelligence Cloud to use new endpoint commit 48f47b8 Author: Mousumi Mohanty <mmohanty@telesign.com> Date: Fri Oct 24 08:45:14 2025 +0000 Pull request #24: feature/EOA-5599-Update-psr-http-message Merge in SDK/php_telesign from feature/EOA-5599-Update-psr-http-message to developer Squashed commit of the following: commit 4be027844b6387198dfd547374363f32da1e4687 Author: MousumiMohanty <@telesign.com> Date: Thu Oct 23 15:46:05 2025 +0530 Updated psr/http-message dependency to allow both v1 and v2
1 parent b7c3190 commit 232cb47

File tree

4 files changed

+82
-41
lines changed

4 files changed

+82
-41
lines changed

RELEASE

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
5.0.0
2+
- Added support for Intelligence Cloud to use new endpoint
3+
14
4.0.2
25
- Added config.php to Composer’s autoload classmap to prevent file-loading errors on case-sensitive systems, while maintaining compatibility with existing integrations.
36

47
4.0.1
5-
- Updated psr/http-message dependency to allow both v1 and v2
8+
- Updated psr/http-message dependency to allow both v1 and v2
69

710
4.0.0
811
- Removed all functionality and methods for App Verify SDK

examples/score/1_check_phone_number_risk_level.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,20 @@
55
use telesign\sdk\score\ScoreClient;
66

77
$customer_id = "FFFFFFFF-EEEE-DDDD-1234-AB1234567890";
8-
$api_key = "EXAMPLE----TE8sTgg45yusumoN6BYsBVkh+yRJ5czgsnCehZaOYldPJdmFh6NeX8kunZ2zU1YWaUw/0wV6xfw==";
8+
$api_key = "ABC12345yusumoN6BYsBVkh+yRJ5czgsnCehZaOYldPJdmFh6NeX8kunZ2zU1YWaUw/0wV6xfw==";
99

1010
$phone_number = "phone_number";
1111
$account_lifecycle_event = "create";
1212

13-
$data = new ScoreClient($customer_id, $api_key);
14-
$response = $data->score($phone_number, $account_lifecycle_event);
13+
$scoreClient = new ScoreClient($customer_id, $api_key);
14+
$response = $scoreClient->score($phone_number, $account_lifecycle_event);
1515

1616
if ($response->ok) {
17-
echo "Phone number $phone_number has a '{$response->json["risk"]["level"]}' risk level"
18-
. " and the recommendation is to '{$response->json["risk"]["recommendation"]}' the transaction.";
17+
echo "Phone number {$phone_number} has a '{$response->json['risk']['level']}' risk level"
18+
. " and the recommendation is to '{$response->json['risk']['recommendation']}' the transaction.";
19+
} else {
20+
echo "Request failed with status code: {$response->status_code}";
21+
if ($response->json !== null) {
22+
echo "\nError details: " . json_encode($response->json);
23+
}
1924
}

src/score/ScoreClient.php

Lines changed: 49 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,53 @@
55
use telesign\sdk\rest\RestClient;
66

77
/**
8-
* Score provides risk information about a specified phone number.
8+
* ScoreClient for TeleSign Intelligence Cloud.
9+
* Supports POST /intelligence/phone endpoint only (Cloud migration).
10+
* Sends phone number and parameters in the request body encoded as application/x-www-form-urlencoded.
11+
* See https://developer.telesign.com/enterprise/docs/intelligence-cloud-get-started for documentation.
912
*/
10-
class ScoreClient extends RestClient {
11-
12-
const SCORE_RESOURCE = "/v1/score/%s";
13-
14-
/**
15-
* Score is an API that delivers reputation scoring based on phone number intelligence, traffic patterns, machine
16-
* learning, and a global data consortium.
17-
*
18-
* See https://developer.telesign.com/docs/score-api for detailed API documentation.
19-
*/
20-
function score ($phone_number, $account_lifecycle_event, array $other = []) {
21-
return $this->post(sprintf(self::SCORE_RESOURCE, $phone_number), array_merge($other, [
22-
"account_lifecycle_event" => $account_lifecycle_event
23-
]));
24-
}
25-
26-
}
13+
class ScoreClient extends RestClient
14+
{
15+
const DETECT_HOST = "https://detect.telesign.com";
16+
const INTELLIGENCE_RESOURCE = "/intelligence/phone";
17+
18+
public function __construct($customer_id, $api_key, $rest_endpoint = self::DETECT_HOST)
19+
{
20+
parent::__construct($customer_id, $api_key, $rest_endpoint);
21+
}
22+
23+
/**
24+
* Obtain a risk recommendation for a phone number using Telesign Intelligence Cloud API.
25+
* Required parameters:
26+
* - phone_number
27+
* - account_lifecycle_event ("create", "sign-in", "transact", "update", "delete")
28+
* Optional parameters include account_id, device_id, email_address, external_id, originating_ip.
29+
* API: POST https://detect.telesign.com/intelligence/phone
30+
*
31+
* See https://developer.telesign.com/enterprise/reference/submitphonenumberforintelligencecloud for detailed API documentation.
32+
*/
33+
public function score($phone_number, $account_lifecycle_event, array $optional = [])
34+
{
35+
if (empty($phone_number)) {
36+
throw new \InvalidArgumentException("phone_number cannot be null or empty");
37+
}
38+
39+
if (empty($account_lifecycle_event)) {
40+
throw new \InvalidArgumentException("account_lifecycle_event cannot be null or empty");
41+
}
42+
43+
$params = array_merge($optional, [
44+
"phone_number" => $phone_number,
45+
"account_lifecycle_event" => $account_lifecycle_event
46+
]);
47+
48+
return $this->post(
49+
self::INTELLIGENCE_RESOURCE,
50+
$params,
51+
null,
52+
null,
53+
"application/x-www-form-urlencoded",
54+
"HMAC-SHA256"
55+
);
56+
}
57+
}

test/score/ScoreClientTest.php

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,30 @@
55
use telesign\sdk\Example;
66
use telesign\sdk\ClientTest;
77

8-
final class ScoreClientTest extends ClientTest {
9-
8+
final class ScoreClientTest extends ClientTest
9+
{
1010
const EXAMPLE_PHONE_NUMBER = Example::PHONE_NUMBER;
1111
const EXAMPLE_ACCOUNT_LIFECYCLE_EVENT = Example::ACCOUNT_LIFECYCLE_EVENT;
1212

13-
function getRequestExamples () {
14-
return [
13+
function getRequestExamples()
14+
{
15+
return
16+
[
1517
[
1618
ScoreClient::class,
1719
"score",
18-
[
19-
self::EXAMPLE_PHONE_NUMBER,
20-
self::EXAMPLE_ACCOUNT_LIFECYCLE_EVENT,
21-
[ "optional_param" => "123" ]
22-
],
23-
self::EXAMPLE_REST_ENDPOINT . "/v1/score/" . self::EXAMPLE_PHONE_NUMBER,
24-
[
25-
"account_lifecycle_event" => self::EXAMPLE_ACCOUNT_LIFECYCLE_EVENT,
26-
"optional_param" => "123"
20+
[
21+
self::EXAMPLE_PHONE_NUMBER,
22+
self::EXAMPLE_ACCOUNT_LIFECYCLE_EVENT,
23+
[ "optional_param" => "123" ]
24+
],
25+
self::EXAMPLE_REST_ENDPOINT . "/intelligence/phone",
26+
[
27+
"phone_number" => self::EXAMPLE_PHONE_NUMBER,
28+
"account_lifecycle_event" => self::EXAMPLE_ACCOUNT_LIFECYCLE_EVENT,
29+
"optional_param" => "123"
30+
]
2731
]
28-
]
29-
];
30-
}
31-
32+
];
33+
}
3234
}

0 commit comments

Comments
 (0)