Hello,
Looking for what is probably some pretty simple PHP help as I’m no expert at all.. FYI, I have CB Developer Package on J!4.2.3 and PHP 8.1.
Issue 1:
I have a Code Field that will be driven by PHP HTTPv2 code for an API call from another website.
Code:
<?php
$client = new http\Client;
$request = new http\Client\Request;
$request->setRequestUrl('https://HIDDENURL NAME.com/simple/price');
$request->setRequestMethod('GET');
$request->setQuery(new http\QueryString([
[b] 'ids' => 'Value of the user field ProjectName',[/b]
'vs_currencies' => 'usd'
]));
$request->setHeaders([
'HIDDENINFO-Key' => 'HIDDENKEYINFO',
'HIDDENINFO-Host' => 'HIDDENINFO.com'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
What I need to do is replace
'Value of the user field UserProjectName' with a field value found inside the user’s CB profile? I assume this should be pretty easy, but I am not great at writing PHP code.
Issue 2:
If given the option to use the PHP-based API call in the following formats, which is the better choice for the code field?
- cURL
- HTTPv1
- HTTPv2
- Unirest/Request
Thanks so much