Hello DaniWeb Community,
I am a newbie in PHP, but I tried to create a plugin for my CRM platform using API to get informations, but I get some errors: Notice: Undefined index. Click here for an image with the errors..
Here are the lines where I got the errors:
`
// API doRequest - Custom Attributes Information
$customAttributes = UCRMAPIAccess::doRequest(sprintf('custom-attributes?attributeType=client')) ?: [];
foreach($customAttributes as $customAttr) {
$responseCA = UCRMAPIAccess::doRequest(sprintf('custom-attributes?attributeType=client'),
'GET',
[
'id' => $cAttributeID,
'key' => $cAttributeKey,
'name' => $cAttributeName,
'attributeType' => $cAttributeType,
'value' => $cAttrValue,
]
);
if($responseCA !== null) {
echo '<ul>';
echo sprintf('<li>ID:</li> %d', $cAttributeID);
echo sprintf('<li>key:</li> %s', $responseCA['key']); // line 117
echo sprintf('<li>name:</li> %s', $responseCA['name']); // line 118
echo sprintf('<li>value:</li> %s', $responseCA['value']); // line 119
echo '</ul>';
} else {
echo 'There was an error retrieving custom attributes.' . PHP_EOL;
}
}
`
And here is where I use $_GET function:
`
// Custom Attributes Information
$cAttributeName = (isset($_GET['name']) ? $_GET['name'] : null);
$cAttributeID = (isset($_GET['id']) ? $_GET['id'] : null);
$cAttributeKey = (isset($_GET['key']) ? $_GET['key'] : null);
$cAttributeType = (isset($_GET['attributeType']) ? $_GET['attributeType'] : null);
`
What I am trying to do aswell, after I get the custom attributes, I want to get them for each client I have:
$cAttributes = (isset($_GET['attributes']) ? $_GET['attributes'] : [
$cAttrName = (isset($_GET['name']) ? $_GET['name'] : null),
$cAttrKey = (isset($_GET['key']) ? $_GET['key'] : null),
$cAttrValue = (isset($_GET['value']) ? $_GET['value'] : null),
$cAttrClientID = $clientId,
]);
This is the $_GET function for Client Custom Attributes
And this is the API doRequest function for clients, where I had added the attributes, but I don't know if I did it right.
// API doRequest - Client Information & Custom Attributes
$response = UCRMAPIAccess::doRequest(sprintf('clients/%d', $clientId),
'GET',
[
'fullAddress' => $cFAddress,
'firstName' => $cFName,
'lastName' => $cLName,
'companyTaxId' => $cCompanyTaxID,
'companyRegistrationNumber' => $cCompanyRegistrationNumber,
'city' => $cCity,
'street1' => $cStreet1,
'street2' => $cStreet2,
'organizationName' => $cOrganizationName,
'invoiceStreet1' => $cInvoiceStreet1,
'invoiceStreet2' => $cInvoiceStreet2,
'invoiceCity' => $cInvoiceCity,
'invoiceZipCode' => $cInvoiceZipCode,
'attributes' => [
'name' => $cAttrName,
'value' => $cAttrValue,
'key' => $cAttrKey,
'id' => $cAttributeID,
],
]
);