We need to test the sms text notifications thru our project which is implemented in PHP. We have used the phone number combine with the carrier gateway. For example 7-11 Speakout (USA GSM) has a gateway #cingularme.com, so while send sms we are combining the number with the gateway as 9860112354##cingularme.com and sending this thru PHP's mail function.
Now wee need to test this on our mobile phones. However we are unabel to find the carrier gateway list for the same (Nokia 6300). Please advise.
Are you looking for a list of carrier email to SMS addresses? Such as ##tmomail.net?
If so, here's an exhaustive list:
http://www.mutube.com/projects/open-email-to-sms/gateway-list/
I had this problem also. The carrier gateway list, as posted out by another answer - is irrelevant to the device, but instead has to due with it's service provider. What you will need to do, is find the carrier - and then fetch it's email to SMS address, to build the e-mail address to send your message to. Such a list can be found on wikipedia.
To get the carrier and service provider of the cellular device, here is a simple function that will provide the cellphone's carrier name when provided with a celluar number:
<?php
// leave this blank - we may never implement an authentication key
$smsarc_API_key = '';
// enter the user's 10 digit cell phone number.
// example format: $smsarc_to = '5556667777';
$smsarc_number = '5192097991';
// lookup carrier
$ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, 'http://www.smsarc.com/api-carrier-lookup.php?sa_number='.$smsarc_number); $AskApache_result = curl_exec ($ch); $smsarc_message_status = $AskApache_result; curl_close($ch);
// print the carrier lookup results
echo $smsarc_carrier;
?>
Developer API from their site:
http://www.smsarc.com/free-php-cell-phone-carrier-lookup/
Related
I was looking for a way to send notifications directly to the customer phone number using the Whatsapp API
I found an article on a site that explains in detail how to activate and use the Whatsapp API.
Add the phone number +34 644 76 66 43 into your Phone Contacts. (Name it it as you wish)
Send this message "I allow callmebot to send me messages" to the new Contact created (using WhatsApp of course)
Wait until you receive the message "API Activated for your phone number. Your APIKEY is 123123" from the bot.
Note: If you don't receive the ApiKey in 2 minutes, please try again after 24hs.
The WhatsApp message from the bot will contain the apikey needed to send messages using the API.
You can send text messages using the API after receiving the confirmation.
Perfect receipt apikey
How to send WhatsApp Messages from PHP using CURL Library
It is very simple to send WhatsApp messages from PHP using the cURL Library. I would recommend to create a function and then call to the function every time that you want to send a message.
First, create the function "send_whatsapp" in your php code as follow:
function send_whatsapp($message="Test"){
$phone="NUMBER"; // Enter your phone number here
$apikey="YOUR_API_KEY"; // Enter your personal apikey received in step 3 above
$url='https://api.callmebot.com/whatsapp.php?source=php&phone='.$phone.'&text='.urlencode($message).'&apikey='.$apikey;
if($ch = curl_init($url))
{
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
$html = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
// echo "Output:".$html; // you can print the output for troubleshooting
curl_close($ch);
return (int) $status;
}
else
{
return false;
}
}
Just update the $phone and $apikey variable with the ones that you obtained during the step 3 above.
And then call to the function from any place in your code.
send_whatsapp("this is a test from PHP"); //Text message that your would like to send
You can call to the send_whatsapp function from different places in your code.
QUESTION
Perfect this will send me a message every time to the number I specified to activate the notification system.
But what if I want to send it not to my number but to the customer number?
I believe you're missing two concepts here. If you want to send messages from your personal phone number, you need to host & run your own solution (I don't think you'd like to allow anybody else out there to get all your stuff).
If you are asking for a service provider to set up a number for you and offer you a gateway service for that purpose, there are several alternatives out there. Google them. You'll find two options; Facebook/Whatsapp API connected providers and 'free riders' that will set that up for you at a cost.
The solution you mention is called call me bot and it is just to send self notifications and not for sending out messages to third parties. I am hosting a similar solution (https://github.com/inUtil-info/whin-use-cases) but is the same situation. To prevent span, you are not allowed to send messages to anyone but you.
This function for Reveres Geocoding works well for me. I have to display the address in the information window of a marker, and there are more then 200 in one map. I built the code below and it works perfectly. However, Google's API request limit of 2500/day gets exceeded easily.
Is there any way in I can bulk request Google's API?
Our project is currently a small one, so buying more requests/day isn't an option for us.
<?php
function getaddress($lat,$lng)
{
$url = 'http://maps.googleapis.com/maps/api/geocode/json?latlng='.trim($lat).','.trim($lng).'&sensor=false';
$json = #file_get_contents($url);
$data=json_decode($json);
$status = $data->status;
if($status=="OK")
return $data->results[0]->formatted_address;
else
return false;
}
?>
No, you can't "bulk query" a bunch of addresses and have it only count as one request when using the standard API. Each lookup counts as a request.
There are other APIs that don't have limits, or allow more lookups, like MapQuest. If you're hitting the daily limit with Google, try using another API.
I'm trying to add a new Deal with the Pipedrive API.
To do so I've followed this tutorial: http://support.pipedrive.com/customer/portal/articles/1271064-how-to-send-in-deals-using-a-web-form
But there's something I didn't understand:
"Email API gives your company a special email address you can use to
automate lead generation and adding of new contacts and
organizations."
Where can I get this email address, there's no other mention of it at the tutorial?
Since I'm unable to follow the tutorial I'm trying to add a new deal with cURL, this is the code:
<?php
$deal = array("item_type" => "deal","stage_id" => 1,"title" => "Atendimento Web Site","organization" => "Company","owner" => "johndoe#company.com.br","visible_to" => 2,"person" => array("name" => $nome,"email" => $email,"organization" => $empresa,"phone" => $tel));
$deal_string = json_encode($deal);
$ch = curl_init('https://api.pipedrive.com/v1/deals?api_token=TOKEN');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $deal_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json, charset=UTF-8',
'Content-Length: ' .strlen($deal_string))
);
echo $deal_string;
echo curl_exec($ch);
?>
And this is what I get:
iten sent -> {"item_type":"deal","stage_id":1,"title":"Atendimento","organization":"Company","owner":"owner#mail.com.br","visible_to":2,"person":{"name":"Jo\u00e3o Neto","email":"mail#mail.com.br","organization":"Company 2","phone":"7112345678"}}
return from api -> {"success":false,"error":"Deal title must be given.","data":null,"additional_data":null}
Where's the error?
About the email support it's true that you are mixing two thing, although it was also happened to me the first time. I admit it would seem strange, an API in which you can use emails.
Anyway, I was working on a simple integration between Pipedrive and another platform and I used the full REST API.
I noticed every time you have an error creating a Deal or you make a mistake in the Json (even if title is ok), you always get the same answer "error":"Deal title must be given.". Of courses it won't help you too much.
So, I recommend you to use some tools like RESTClient for Firefox to simplify the problem at the beginning or even Firebug to sniff it from https://developers.pipedrive.com/v1 making use of their tools to understand the request a little bit better. After that, you can do it more complex.
I am putting you a screenshot in which you can see the simplest example. I hope it will be useful for anyone
I'd receive an email from Pipedrive Support with a full anwser.
*Hi,
Thanks for reaching out!
I'm sorry to hear about the trouble!
So you're mixing up two completely separate things. You're sending in the JSON object needed for the Email API into the REST API.
You have 2 options.
You could go full on with the email API. To do this you need to log into your Pipedrive account, navigate to the Settings, Features page and enable the Email API feature. Then click through to the email API page and get the email address you need to send the object to. And then alter your PHP code to send in that object to that email address as a plain text email. No curl or API token needed for that.
You could clean up the data object you're sending in with the REST API. But you need to understand that the REST API works a little different from the Email API. So you can't just send in the person object along with the deal. You would first need to POST in the person with all the details to the persons endpoint and get back the ID. You can then use the person ID in the deals POST.
I hope this helps
Martin Henk | Co-Founder, Head of Customer Support
Pipedrive*
I would like to send notifications from my webserver to my smartphone, preferably through one of the popular mobile chat apps like WhatsApp, Viber or Kik.
Is there any known documentation or API or something, that describes how to send a message to these clients, for example using PHP?
Note that I only need to be able to send notifications to my own smartphone, so requiring specific info to identify my particular client (like cellphone number or something) is fine.
There are many web services that allows you to send and receive SMS/notifications. PHP itself doesn't support this on it's own. You can use a service like Twilio to do this. You can send messages to your own smartphone, or even a friend's.
An example:
<?php
require "Services/Twilio.php";
// Step 2: set our AccountSid and AuthToken from www.twilio.com/user/account
$AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$AuthToken = "YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY";
// Step 3: instantiate a new Twilio Rest Client
$client = new Services_Twilio($AccountSid, $AuthToken);
// Step 4: make an array of people we know, to send them a message.
// Feel free to change/add your own phone number and name here.
$people = array(
"+14158675309" => "Curious George",
"+14158675310" => "Boots",
"+14158675311" => "Virgil",
);
// Step 5: Loop over all our friends. $number is a phone number above, and
// $name is the name next to it
foreach ($people as $number => $name) {
$sms = $client->account->sms_messages->create(
// Step 6: Change the 'From' number below to be a valid Twilio number
// that you've purchased, or the (deprecated) Sandbox number
"YYY-YYY-YYYY",
// the number we are sending to - Any phone number
$number,
// the sms body
"Hey $name, Monkey Party at 6PM. Bring Bananas!"
);
// Display a confirmation message on the screen
echo "Sent message to $name";
}
See the documentation here.
Hope this helps!
Why won't the rate work with USPS? I'm using ratev4 and I get an error:
Error:
API Authorization failure. RateV4 is not a valid API name for this protocol.
UspsCom::DoAuth
Here is my code:
<?php
$devurl = "testing.shippingapis.com/ShippingAPITest.dll";
$puburl = "https://secure.shippingapis.com/ShippingAPITest.dll";
$service = "RateV4";
$userid = "690DEVBL1739";
$xml = rawurlencode('<RateV4Request USERID="xxxxx">
<Revision/>
<Package ID="1ST">
<Service>FIRST CLASS</Service>
<FirstClassMailType>LETTER</FirstClassMailType>
<ZipOrigination>44106</ZipOrigination>
<ZipDestination>20770</ZipDestination>
<Pounds>1</Pounds>
<Ounces>0.0</Ounces>
<Container/>
<Size>REGULAR</Size>
<Machinable>true</Machinable>
</Package>
</RateV4Request>');
$request = $devurl . "?API=" . $service . "&xml=" . $xml;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $request);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_HTTPGET, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo "<pre>";
print_r($response);
echo "</pre>";
I assume that you have already registered for USPS Web Tools here:
https://secure.shippingapis.com/registration/
And have received confirmation from USPS that your account is active:
If you need to set up USPS or your customers are receiving this error on check out (See below) you should confirm the following
Confirm that our USPS API access is approved
Confirm that it is not in test mode and is in production mode
If USPS says your account is active, this does not mean it is in production mode, - you need to call USPS and specifically request that it be moved to production mode after your account has been approved. A good idea is to perform this quick test:
Insert the following into your browser with your own USERID in place of the XXXX in the URL of any browser:
https://secure.shippingapis.com/ShippingAPITest.dll?API=CarrierPick... USERID="XXXX">ABC Corp.Suite 7771390 Market StreetHoustonTX770581234
If your USPS account is active, it should accept the username.
Confirm that your username and password is for this site only. USPS only allows 1 domain per account.
http://production.shippingapis.com/ShippingAPI.dll
The problem is that by default, you don’t have access to USPS’s production API. They have to approve you first. Keep in mind that they only allow you to use it on one web site per account, so if you’re setting Magento up for a client, customer, or other business entity other than your own you should set up a separate USPS account for them.
That's why you're receiving this text - "Sample Do Not Mail" over the generated shipping label.
You can set up your USPS WebTools account here:
http://www.usps.com/webtools/
Once you have set up your account, they will give you access to the testing environment. The URL for the USPS test API is: http://testing.shippingapis.com/ShippingAPITest.dll
I recommend asking USPS to turn on production mode. When you are approved by USPS for the production API, you should use the following URLs:
http://production.shippingapis.com/ShippingAPI.dll
https://secure.shippingapis.com/ShippingAPI.dll
When you have completed your testing, email the USPS Internet Customer Care Center (ICCC). They will switch your profile to allow you access to the production server and will provide you with the production URLs.
The ICCC is staffed as follows: Monday through Friday from 8:00AM to 8:30PM Eastern Time Saturday from 8:00AM to 6:00PM Eastern Time Sunday and Postal Holidays - Closed except for the following Holidays: Martin Luther King; President's Day; Columbus Day; & Veteran's Day with hours from 9:00AM to 6:00PM Eastern Time
E-mail: uspstechsupport#esecurecare.net Telephone: 1-800-344-7779
But remember, it’s very important that you set up a separate USPS account for each web site (or at least one per domain). USPS will disable your access to their production server if you are caught using your account on multiple web sites.
To request access to the USPS production API, fill out the form here: http://www.usps.com/webtools/webtoolsapirequestform.htm
USPS doesn’t allow you to use their API for batch processing or data cleansing, so be sure to NOT check these boxes on the request form.
Once USPS gives you access to their production API server, everything should work corresponding to all USPS shipping options. If you are still having trouble, again check that you have access to USPS’s production API server.
I had the same problem. RateV4 is not valid for the USPS's test server, only production. I contacted their support people and tried to get a valid API for test but all they ever sent was a link to their documentation (which only contains production APIs, not test). In the end I just asked them to move my account to production and they did.
I've had the same issues with testing Ratev4 (and v2 for intl shipments) stuff. Just asking them to move you to production fixed that easily , but make sure you use the right urls of course.
Other than that, from what I understand your setup wouldn't work anyway, because you're asking for a rate for first class and the weight is 1 pound. First class only goes up to 13 ounce...