Hi, I am working with the API to generate telecom bills to customers straight from my VOIP gateway on a monthly basis. I need to attached their Call records as a PDF to their Invoice so they can download and check the calls made. I have done this manually ( very time consuming for 50 companies!) for some time and now its just too time consuming.
I have looked at the document upload type for attaching the ducument to an Invoice ID and notice the Cdata ( EmbeddedFileBinaryObject). I cannot find any examples for getting/generating the neccessary info for this XML field and have become rather stuck. Help most appreciate
Ok, great. So that file I’m assuming is saved locally, or returned as a string?
If it’s the former, you can do something like this:
/** Get the contents of the file */
$file = file_get_contents("../path/to/file.pdf");
If it’s in a string already, then no need to do this as that step would load the file into a string for you. From there, you encode the string using Base64:
/** Take the file string and encode it using Base64 */
$data = base64_encode($file); `
When it comes to compiling the XML, you set the value of EmbeddedFileBinaryObject to the new base64 string.