Send SMS from VoIP Drupal
Considering you configured your VoIP Drupal with one of the providers, here is the sample code snippet that sends "Hello world" SMS:
<?php
$number = '+1234567890123'; //Number to send SMS to. Must be in E.164 format.
$call = new VoipCall();
$call->setDestNumber($number);
$text = 'Hello from VoIP Drupal';
voip_text($text, $call);
?>
Pretty cool, right?
Drupal Balkan Summit: VoIP Drupal and building SMS service using any local phone number
Last week I held a session in Drupal Balkan Summit about VoIP Drupal and building SMS service using any local phone number.
In the video below you can see how to use Envaya SMS with VoIP Drupal in order to build SMS service which can receive and send text SMS messages using your local SIM number.
Drupal 7 check if user is logged in from javascript
Drupal 7 comes with jquery cookie plugin which can be find under
misc/jquery.cookie.js
This plugin can be used to check if user is logged in or not directly from Jquery. We do that by checking if the cookie DRUPAL_UID exists and its value is not equal to 0.
Theming Drupal 7 user login page
Since I didn't find a good tutorial for theming the Drupal login page I wrote one here.
Getting a page template for the user login page should be as easy as copying your page.tpl.php file and renaming it to page--user-login.tpl.php. Problem is when I tested this It didn't run on /user but only on /user/login page. To get the same template file to run on both you must add to your template.php:
Submit Drupal user registration form to Hubspot
Today I am going to show you how to create a small module that submits results of Drupal user registration form to Hubspot. For those who doesn't know, HubSpot provides advanced targeting marketing and lead nurturing features. You can read more about it at their website: http://www.hubspot.com/
We will call our module hubspot_user.module. First of all we need to create admin configuration form where you can enter three things:
Submit a form using Javascript
Usually form is submitted when the user press on a submit button. But , sometimes, you may need to submit the form programmatically using JavaScript.
JavaScript provides the form object that contains the submit() method. Use the 'id' of the form to get the form object.
For example, if the name of your form is 'myform', the JavaScript code for the submit call is:
document.forms["myform"].submit();
But, how to identify a form? Give an id attribute in the form tag:
Check if a file exists in Amazon S3
If you are looking for a way to check if a file exists in Amazon S3 bucket using Amazon S3 PHP library, then probably this may help you.
Simplest way is to use function getObjectInfo()
<?php
//initiate the class
$s3 = new AmazonS3();
$info = $s3->getObjectInfo($bucket, $filename);
if ($info){
//File exists
}
else{
//File doesn't exists
}
?>
This function will return FALSE if $filename doesn't exists in Amazon S3 bucket.
Open Drupal modules in Notepad++ using PHP markup
If you are working everyday with Drupal module development you know how frustrating can be that each time you open a module file its show in plaintext instead of in PHP format. Well there is a easy solution, open up your Notepad++ and go to Settings -> Style Configurator.
Depending on which language color syntax you want for the file extension, under Language, select the language.
Select php under Language.
PHP get image from byte array
So in previous blog post we talked about saving image to byte array in order to pass it to backend SOAP service. But how about retrieving such image from backend?
Well the logic is similar, so considering you have the byte array returned from SOAP, you will create new php file named image.php:
PHP convert image to byte array
Recently I worked on integration between Drupal CMS with backend SOAP service and encountered a problem with saving image to the backend. The backend required image to be passed as byte array. Googling around I was suprised to find out answers like "I don't think PHP has such low level control..." or "change your backend service...". Eventually after not finding anything useful I decided to tackle the issue myself and soon I came up with a solution which is actually very easy.