I am using the Xero PHP SDK (This one https://developer.xero.com/code-samples/libraries/php/) and I am able to post an invoice with no problems.
However, I am having issues understanding how I can retrieve the posted invoice's PDF, as I need to manually email this to the customer.
I believe the standard invoice request should be formatted thusly, but this will return all invoices.
$XeroOAuth->request('GET', $XeroOAuth->url('Invoices', 'core'), array());
My Question, therefore, is using the above SDK and call format how would I…
Target a specific invoice by its ID
Retrieve a PDF of the said invoice.
Some code examples would really help me out. Thanks!
To get the PDF output use the following
<?php
$response = $XeroOAuth->request('GET', $XeroOAuth->url('Invoice/'.$InvoiceID, 'core'), [], "", 'pdf');
if($XeroOAuth->response['code'] == 200){
$myFile = $invoices->Invoices[0]->Invoice->InvoiceID.".pdf";
file_put_contents($myFile, $XeroOAuth->response['response']);
}
Related
I'm having trouble implementing webhooks in FluidReview (used to be SurveyMonkey Apply). Specifically, I want to send a webhook with the applicant and current application status, triggered upon any change in application state, so that we can update our CRM with the latest status data. The problem is that I can't figure out setup the webhooks in FluidReview, and their documentation is abysmal (Fluid Review Webhooks, Fluid Review Triggers). Can anyone help me out by providing an example of setting up a simple or advanced webhook?
Steps followed thusfar:
1) I have a php endpoint on my wordpress site that uses the following code snippet to save the JSON from a webhook to the error log:
if(isset($_GET['fr-listener']) && $_GET['fr-listener'] == 'fr') {
error_log("fr-listener==fr hook caught!");
if($json = json_decode(file_get_contents("php://input"), true)) {
// if($json = json_decode(file_get_contents("php://input"), true)) {
error_log("JSON found");
error_log(print_r($json,true));
error_log(var_dump($json));
// $data = var_export($json, true);
// error_log("data dump: " + $data);
// print_json($json);
} else {
error_log("no JSON found");
print_r($_POST);
$data = $_POST;
}
}
I can use this to successfully catch webhooks from Stripe (I used the above snippet to help develop my Stripe webhook catcher) and get a look at their JSON contents. When I catch one of the webhooks from FluidReview, I get the "no JSON found" response. This is how I have the webhook set:
My Webhook Action
(URL = https://wfadev.pairsite.com/listen?fr-listener=fr, Method = POST, Request content = {{applicant.email}})
2) I have tried both setting simple and advanced webhooks, and neither of them are producing the JSON output I'd expect.
I did some more testing and it turns out that the "Request content" field is just a blank text field. To have it send JSON data from FluidReview, write it out like this, using the piping variables ("{{variable name}}")
{
"first_name": "{{user.first_name}}",
"last_name":"{{user.last_name}}",
"email":"{{user.email}}",
"application_type":"{{user.}}",
"date":"{{date}}",
"trigger":"{{trigger}}"
}
I'm just wondering if it's available to fetch list of all payments from SagePay. I'm currently able to get transaction details by providing transaction_id and send request to https://sagepay.com/api/v1/transactions/{$transaction_id}. I'm currently getting all payments by CSV export from SagePay dashboard, but I would like to automate it. Thank you in advance for help.
You can use the 'old' API to achieve this - just issue a getTransactionList command.
Documentation at: https://www.sagepay.co.uk/file/1186/download-document/reportingandapiprotocol102v0.5.pdf
You can do it easily, just give the required fields in the xml form and send request to respective url.
$crypt = MD5($string . '<password>' . $password . '</password>');
$xml = 'XML=<vspaccess>'.$string.'<signature>'.$crypt.'</signature>
</vspaccess>';
where $string is the whole xml before the password.
It will also help you making the signature field in xml syntax.
Read this pdf (page 85 for you) :-)
Good day,
Im creating reminder app that calls a number in certain time, currently I was using an uploaded mp3 file on my server:
here the code:
$sid = "ACxxxxxxxxxx";
$token = "2xxxxxxxxx";
$client = new Client($sid, $token);
$call = $client->calls->create(
"$phone_number_to","$phone_number_from",
array("url" =>
"https://xxxxx.com/asset/mp3/reminder.mp3")
);
$csid = $call->sid;
the above code works, but now I wanted to use the text to speech feature on twilio to have a more customized voicemail per reminder..
how do I do this using $client-> api? Im not really familiar on how TwiML works though, maybe thats why im confused.
thanks!
You change this line of your current code "url" => "https://xxxxx.com/asset/mp3/reminder.mp3" so that the URL points at the url hosting the script you want to use to generate your dynamic TwiML.
Then use the php TwiML library to generate the TwiML, it's pretty straightforward. We have a database with all out customers details in, I use code something along these lines to get their details based on caller ID and have Twilio greet them by first name:
$booked = SELECT * FROM table WHERE phone = $caller;
$name = explode(" ", $booked->name);
$firstname = $name[0];
$response->say("Hello $firstname. Thanks for calling......");
It's ok but it's a bit robotic. We ended up extracting the 50 most common first names from the database and having a voiceover artist record greetings for each one. For callers with one of those 50 names we serve a specific mp3 file, everyone else gets the robot.
I'm trying to get list of invoices for specific customer from Stripe using PHP.
Following is the code I'm using.
\Stripe\Stripe::setApiKey('STRIPE_SECRET_KEY');
$response = \Stripe\Invoice::all(array('customer' => 'CUSTOMER_TOKEN'));
But this returns empty array.
Instead, CURL command returns result
curl https://api.stripe.com/v1/invoices?customer=CUSTOMER_TOKEN -u STRIPE_SECRET_KEY
Any idea?
I'm using Stripe PHP library available from Github.
https://github.com/stripe/stripe-php
$response = \Stripe\Invoice::all(array('customer' => 'cus_id'));
You need to add customer id for specific customer.
I have got a successful oauth TripIt granting process using the same methodology that is used to connect and authenticate users against the LinkedIn and Twitter APIs in PHP (PECL Oauth etc).
However, whenever when I do a valid request (ie a 200 response... no 401 nor 404), all I get in response is:
<Response><timestamp>1301411027</timestamp><num_bytes>80</num_bytes></Response>
I want to list the authenticated user's profile and trip data... The API docs (the pdf) is a bit sketchy on how to do this when the actual user id isn't known, but here are the queries I have attempted:
https://api.tripit.com/v1/list/trip
https://api.tripit.com/v1/list/trip/traveler/true
https://api.tripit.com/v1/get/profile
All returning the same response (as part of the oauth class "last response" method). This is where the LinkedIn API response contents can be found... so what is going on with TripIt? :P
It took a bit of experimenting, but here's an example of one that appears to be working to return data.
$response = $TripIt->_do_request('get/profile');
EDIT:
This one is likely the preferred method.
$response = $TripIt->_do_request('get', 'profile');
I've gone one step further and thrown it into an XML parser.
$response = $TripIt->_do_request('get', 'profile');
$profile = new SimpleXMLElement($response);
Here is one I'm using to get past trips. That third parameter is the one to use for filters.
$response = $TripIt->_do_request('list', 'trip', array('past'=>'true' );
$trips = new SimpleXMLElement($response);