cancel
Showing results for 
Search instead for 
Did you mean: 
Post a Question

using checkpoint management api web service with php

Jump to solution

Hi,

has anybody some code examples how to use web service api with php. I think a good way is to use php cURL but i don't have a clue how to start. I think that Ekta Siwani‌ was using php with api.

Thanks in advance.

Felix

Tags (2)
1 Solution

Accepted Solutions
VENKAT_S_P
Copper

Re: using checkpoint management api web service with php

Jump to solution

I use PHP, post method, use cURL get request/response from json and display the error.

Do not verify the peer and verify host otherwise it will give the SSL error.

Sample code:

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
CURLOPT_URL => "https://Mgmt_IP/web_api/login",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",

CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_POSTFIELDS => "{\r\n \"user\" : \"admin\",\r\n \"password\" : \"#@$1@#\"\r\n}",
CURLOPT_HTTPHEADER => array(
"Cache-Control: no-cache",
"Content-Type: application/json",
),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}

3 Replies
Admin
Admin

Re: using checkpoint management api web service with php

Jump to solution

I haven't seen many code examples with PHP.

We do have one with Python, though: CPAPI - Web API Tool

0 Kudos
VENKAT_S_P
Copper

Re: using checkpoint management api web service with php

Jump to solution

I use PHP, post method, use cURL get request/response from json and display the error.

Do not verify the peer and verify host otherwise it will give the SSL error.

Sample code:

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
CURLOPT_URL => "https://Mgmt_IP/web_api/login",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",

CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_POSTFIELDS => "{\r\n \"user\" : \"admin\",\r\n \"password\" : \"#@$1@#\"\r\n}",
CURLOPT_HTTPHEADER => array(
"Cache-Control: no-cache",
"Content-Type: application/json",
),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}

Re: using checkpoint management api web service with php

Jump to solution

Thank you VENKAT S P, exactly what I was looking for!