I'm trying to use the Twilio API to buy a phone number with a "Local" address requirement on behalf of a customer using the "Connect" API.
The purchase request looks like this:
$twilio = new \Twilio\Rest\Client($customerConnectedSid, env('TWILIO_AUTH_TOKEN'));
$numberRes = $twilio->incomingPhoneNumbers->create([
'phoneNumber' => $numberString,
'addressSid' => $user->company->twilio_address_sid,
]);
The error I get back from Twilio is:
[HTTP 400] Unable to create record: Could not find Address with sid AD*** for account AC*** to satisfy Local Address requirement
I don't know why it can't "find" that address because both the accountSid and sid match in the response from:
$twilio->addresses->read([], 100)
So clearly the address exists.
I think I just figured it out, but I'm going to leave the question up anyway in case someone else encounters it.
The error message is just bad.
It can "find" the address, but it doesn't satisfy the local address requirement.
Make sure the address is actually for the region where the phone number is.
Related
I am trying to do the following with the DocuSign API, but I am not getting very much wiser from their documentation.
The admin creates the envelope in DocuSign just as they normally would, but without sending it
They take the Envelope ID and enter it in our software
We show a button to the end user that sends out the Envelope signature request when clicked (based on the Envelope ID)
The closest I came to finding something like this was https://developers.docusign.com/docs/esign-rest-api/how-to/request-signature-email-remote/ but that doesn't seem to allow me to use and existing envelope.
The API reference doesn't seem to offer any help either (https://developers.docusign.com/docs/esign-rest-api/reference/envelopes/envelopes/)
What I have got so far is the following:
OAuth + generating the JWT + access token (works fine)
generating Recipient View (which is not what I need but needs to be replaced with the right call
$view_request = new \DocuSign\eSign\Model\RecipientViewRequest(['return_url' => $args['ds_return_url']]);
if ($args['starting_view'] == "envelope" && $args['envelope_id']) {
$view_request->setEnvelopeId($args['envelope_id']);
}
# Call the API method
$config = new \DocuSign\eSign\Configuration();
$config->setHost($args['base_uri']);
$config->addDefaultHeader('Authorization', 'Bearer ' . $args['ds_access_token']);
$api_client = new \DocuSign\eSign\Client\ApiClient($config);
$envelope_api = new \DocuSign\eSign\Api\EnvelopesApi($api_client);
$results = $envelope_api->createRecipientView($args['account_id'], $view_request);
$view_url = $results['url'];
return $view_url;
Thanks!
So based on your description it looks like for the first step, you're looking to create an envelope as a draft. Which is basically creating an envelope, filling all the information out, and then not sending it.
This will spit out an envelope Id which you can store in your application.
And when the button you describe is clicked, you can update the status of the envelope to "sent" using this endpoint which will send out the envelope.
If you're looking for something more detailed, you can always reach out to us at DocuSign Developer Support and we can discuss it further.
I am using zend framework to send emails. I have an Hostname::ALLOW_DNS validator. It fails when trying to send email to yahoo.gr. I get this error:
An error occurred
An error occurred during execution; please try again later.
Additional information:
Zend\Mail\Exception\InvalidArgumentException
File:
/var/www/file/project/vendor/zendframework/zendframework/library/Zend/Mail/Address.php:41
Message:
'yahoo.gr ' is not a valid hostname for the email address
The email is smth#yahoo.gr. Any suggestions?
From your error, the only problem I can see is the whitespace 'yahoo.gr ' which will/can cause failure of validation.
Fix Suggestion 1:
You should start using trim() on your GET/POST "email" value.
Fix Suggestion 2:
Which is by the way in the documentation:
Validating only the local part
If you need Zend\Validator\EmailAddress to check only the local part of an email address, and want to disable validation of the hostname, you can set the domain option to FALSE. This forces Zend\Validator\EmailAddress not to validate the hostname part of the email address.
$validator = new Zend\Validator\EmailAddress();
$validator->setOptions(array('domain' => FALSE));
Fix Suggestion 3:
Which is by the way in the documentation as well:
Validating different types of hostnames
The hostname part of an email address is validated against Zend\Validator\Hostname. By default only DNS hostnames of the form domain.com are accepted, though if you wish you can accept IP addresses and Local hostnames too.
To do this you need to instantiate Zend\Validator\EmailAddress passing a parameter to indicate the type of hostnames you want to accept. More details are included in Zend\Validator\Hostname, though an example of how to accept both DNS and Local hostnames appears below:
$validator = new Zend\Validator\EmailAddress(
Zend\Validator\Hostname::ALLOW_DNS |
Zend\Validator\Hostname::ALLOW_LOCAL);
if ($validator->isValid($email)) {
// email appears to be valid
} else {
// email is invalid; print the reasons
foreach ($validator->getMessages() as $message) {
echo "$message\n";
}
}
Well, no more suggestions. I wish you good luck!
The End.
Recently I'm trying to received sms to plivo number. when i sent a sms from outsite plivo then it sent and plivo log status will show delivered. But i need to save data into database. It does not trigger to my controller function.
I already sent sms through another function. it sent and saved into my database but problem is, when anyone reply into this number.
controller function:
public function index()
{
// Sender's phone numer
$from_number = $this->input->get("From"); // $this->input->post("From"); dosen't work.
// Receiver's phone number - Plivo number
$to_number = $this->input->get("To"); // $this->input->post("To"); dosen't work.
// The SMS text message which was received
$text = $this->input->get("Text"); // $this->input->post("Text"); dosen't work.
// Output the text which was received to the log file.
// error_log("Message received - From: ".$from_number.", To: ".$to_number. ", Text: ".$text);
$arr = array("from" => $from_number, "to" => $to_number, "text" => $text);
$this->receive_model->add($arr);
}
Plivo application URL :
http://xxxxxxx.com/receive_sms
Message Method : GET
Message Method : POST // Dosen't work.
Codeigniter Config:
$config['allow_get_array'] = TRUE;
In plivo log status delivered.
any help?
Plivo started their Stop DND protocol a few days ago (i.e. June 2016). When a message comes back in response to a text from a Plivo phone number that says Stop... all further messages from Plivo are blocked.
The Plivo number sends a message and the recipient responds with Stop.
There is no do over. From then on, NO messages from Plivo will be delivered to that recipient as the recipients Stop message is interpreted as a request that all further messages be blocked.
Plivo offers no way of turning message delivery back on. That user has no way of correcting the Stop if sent in error. There is no do over.
All solutions lead to using a new different phone number.
A band aid... Incoming messages to that Plivo number still get received so there is the possibility of sending outgoing response messages from a second Plivo or other number. In theory looks OK BUT in reality this is at best a short term fix.
Most users naturally depend on sending messages by replying. Replying to the wrong new incoming number, instead of sending to the original phone number, just sets up another set of problems and issues to deal with. Not the least of those is what ever reason that caused the stop message in the 1st place or accidentally doing it again. Ends up like cutting your finger off 1/16th of an inch at a time.
At the first time i load plivo library class on the sms received controller, it was a problem. I just erase those line from controller and then it works fine.
We have to follow:
Plivo application always get data for codeigniter function. Codeigniter Config: $config['allow_get_array'] = TRUE; SMS received controller only load Codeigniter library file, nothing else.
It works for me.
Sending twilio message from my api returns this error
Twilio sending message The requested resource /2010-04-01/Accounts//Messages.json was not found
this is how I send a message. anyone incountered a problem?
$this->client = new \Services_Twilio($sid, $token);
return $this->client->account->messages->sendMessage($from ,$to, $message);
this is the documentation I followed
https://www.twilio.com/docs/api/rest/sending-sms
How do I create Messages.json
I used this https://github.com/twilio/twilio-php on laravel 4.2
Another Twilio developer evangelist here. Think I might be able to help.
The error message you got was this:
The requested resource /2010-04-01/Accounts//Messages.json was not found
The key point is the URL, particularly the double slash in the middle. That is where your Account Sid should be, thus leading to the 404 error.
In this case, I would double check how you are setting $sid. Make sure it is assigned before you try to create the Twilio client object.
Hi Twilio developer evangelist here.
Sorry to hear you're having trouble with your code.
You seem to not have posted your complete code, so I don't see where you actually require the library.
I have however written an example which worked for me.
// Your Account Sid and Auth Token from twilio.com/user/account
$sid = 'AC';
$token = '01';
$client = new \Services_Twilio($sid, $token);
$message = $client->account->messages->sendMessage(
'+44', // From a valid Twilio number
'+44', // Text this number
"Hello monkey!"
);
I have removed some sensitive data on the code, but if you replace that with your token and numbers, you should be able to send a text message correctly.
Also, just in case you have the contents of the 'Services' folder elsewhere, make sure your paths are correct.
You have entered messages when it should be sms_messages.
CHANGE
$this->client->account->messages->sendMessage($from ,$to, $message);
INTO
$this->client->account->sms_messages->create($from ,$to, $message);
Also make sure that you are running this code inside a class otherwise you need to remove the $this-> from your code and use a local varible.
I'm trying to create a ticket in osticket through its REST API (https://github.com/osTicket/osTicket-1.7/blob/develop/setup/doc/api/tickets.md)
The problem is /api/tickets.json returns 404. I have it installed in a server on osticket folder (something like http://my.net.work.ip/osticket/api/tickets.json - 404)
Also, I've tried to CURL the server (logged in through ssh), created an APIKey for the server's IP address and had the same response.
What am I missing here?
Thank you
So, I had to add http.php after api/ (/api/http.php/tickets.json) and now I can create tickets.
Check http://tmib.net/using-osticket-1812-api. The sample used has this info in the comments.
The two really important parts are on lines 18 and 19.
'url'=>'http://your.domain.tld/api/http.php/tickets.json', // URL to site.tld/api/tickets.json
'key'=>'PUTyourAPIkeyHERE' // API Key goes here
//Edit line 18 to have your URL.
//Edit line 19 by changing "PUTyourAPIkeyHERE" to your API key (aka the "THISISAFAKEAPIKEYHERE!" from earlier).
The piece that seems to be missing from the docs is how to pass the API key. Through a bit of testing and the script mentioned above, I found the X-API-Key header. That means you can create tickets without using a script, you can use curl as easily as:
curl -X POST -H "X-API-Key: 1234567890ABCDEF" -v -d'{"autorespond":false, "source": "API", "name": "Doctor Who", "email":"who#tardis.com", "subject":"Have you seen my Tardis key?", "message":"I have managed to lock myself out of the Tardis, can you send me a spare key?"}' http://support.gallifrey.org/api/tickets.json
This will only work if it is run from the IP address you specified when you created the API key.
Besides changing lines 18 and 19 you need to make sure that you have the correct IP address. You can check that by going to your site here: http://your.domain.tld/support/scp/logs.php
Then look to see if you get the error API Error (401). If you do then look at the IP address and create a new API key for that IP address.
The problem I was facing was I typed in my IPv4 address, but the server was getting my IPv6 address.