APIs & Integrations

Not applicable

403 Error posting data with PHP or AJAX

SOLVE

I read that AJAX automatically doesn’t work with the API so I tried PHP. I send data with this code:

$data = array(
‘values’ => array(
‘3’ => 7,
‘4’ => “New Row Text”
)
);

$options = array(
‘http’ => array(
‘method’ => ‘POST’,
‘content’ => json_encode( $data ),
‘header’=> “Content-Type: application/json\r\n” .
“Accept: application/json\r\n”
)
);

$context = stream_context_create( $options );
$result = file_get_contents(“https://api.hubapi.com/hubdb/api/v1/tables/300081/rows?hapikey=XXXXX”, false, $context );
$response = json_decode( $result );

Error:
Warning: file_get_contents(https://api.hubapi.com/hubdb/api/v1/tables/300081/rows?hapikey=XXXXX😞 failed to open stream: HTTP request failed! HTTP/1.0 403 Forbidden

I’m still using AJAX to call a PHP file through POST and then I do the same with PHP and the url.

0 Upvotes
1 Accepted solution
Solution
Not applicable

403 Error posting data with PHP or AJAX

SOLVE

THIS is what should be used for PHP

View solution in original post

0 Upvotes
2 Replies 2
Solution
Not applicable

403 Error posting data with PHP or AJAX

SOLVE

THIS is what should be used for PHP

0 Upvotes
Not applicable

403 Error posting data with PHP or AJAX

SOLVE

If my code is invalid can someone provide me with some form of code that would work with php?

0 Upvotes