Navbar
Java PHP C# Python NodeJS
  • SDK
  • SDK

    Apifon’s SDK makes it simple for you to use our REST APIs and execute a wide range of server side coding tasks. You will find the most popular programming languages in these SDK helper libraries.

    SDK Explanation

    OAuth2 Example

    // Retrieve an OAuth Configuration for your client credentials and your requested scopes.
    OAuthConfiguration oauthConfig = OAuthConfigurationBuilder
                .getClientCredentialsBuilder(clientId, clientSecret)
                .withScopes(scopes)
                .build();
    // Add the OAuth configuration to Mookee Instance with a key
    Mookee.addOAuthResource(OAUTH_IDENTIFIER, oauthConfig);
    // Retrieve an OAuth2 token from the Identity server with that key
    Mookee.retrieveClientCredentialsToken(OAUTH_IDENTIFIER);
    // Set Mookee to OAuth mode so that OAuth2 is used for any subsequent API calls.
    // Any REST calls executed from the SDK will be OAuth2 enabled.
    Mookee.setMookeeToOAuthMode(OAUTH_IDENTIFIER, true);
    ...
    // Revoke active bearer token for the given key
    Mookee.removeOAuthResource(OAUTH_IDENTIFIER, true);
    
    <?php
    
    use Apifon\Mookee;
    use Apifon\Model\request\OAuthConfigurationRequest;
    require_once("../Apifon/Mookee.php");
    require_once("../Apifon/Model/Request/OAuthConfigurationRequest.php");
    
    //give any identifier name for the given OAuth configuration
    $oauth_identifier = "Type an identifier name";
    
    //fill in your clientId/clientSecret from the mookee platform
    $oauth_configuration = new OAuthConfigurationRequest("Type your clientId", "Type your clientSecret");
    
    //setStaging flag, if true requests will be made to the staging environment, false (default) is for production.
    Mookee::setStaging(false);
    
    //set OAuth identifier along with the OAuth configuration object
    Mookee::add_OAuth_resource_and_get_token($oauth_identifier, $oauth_configuration);
    
    //set the Mookee object to OAuth mode
    Mookee::set_mookee_to_oauth_mode($oauth_identifier, true);
    
    //set active identifier to make an api call
    Mookee::getActive_oauth_token_to_make_an_API_call($oauth_identifier);
    ...
    //remove oAuth resource for given identifier
    Mookee::remove_OAuth_resource($oauth_identifier);
    
    -
    
    -
    
    -
    

    SMS Example

    Mookee.addCredentials("sms", "Your_SMS_Token", "Your_SMS_Secret_Key");
    Mookee.setActiveCredential("sms");
    
    String[] nums = {"306999999999"/*, "306999999998", "306999999997", ...*/};
    ArrayList<String> numbers = new ArrayList();
    numbers.addAll(Arrays.asList(nums));
    
    SMSResource smsResource = new SMSResource();
    SmsRequest smsRequest = new SmsRequest();
    
    MessageContent msgContent = new MessageContent();
    msgContent.setText("Hello There!");
    msgContent.setSenderId("Apifon");
    
    smsRequest.addStrSubscribers(numbers);
    smsRequest.setMessage(msgContent);
    
    GatewayResponse response = smsResource.send(smsRequest);
    printResult(response);
    
    <?php
    
    use Apifon\Mookee;
    use Apifon\Model\SmsRequest;
    use Apifon\Model\MessageContent;
    use Apifon\Resource\SMSResource;
    
    require_once("./Apifon/Model/IRequest.php");
    require_once("./Apifon/Model/SubscribersViewRequest.php");
    require_once("./Apifon/Mookee.php");
    require_once("./Apifon/Security/Hmac.php");
    require_once("./Apifon/Resource/AbstractResource.php");
    require_once("./Apifon/Resource/SMSResource.php");
    require_once("./Apifon/Response/GatewayResponse.php");
    require_once("./Apifon/Model/MessageContent.php");
    require_once("./Apifon/Model/SmsRequest.php");
    require_once("./Apifon/Model/SubscriberInformation.php");
    
    Mookee::addCredentials("sms","Your_SMS_Token", "Your_SMS_Secret_Key");
    Mookee::setActiveCredential("sms");
    
    $smsResource = new SMSResource();
    $smsRequest = new SmsRequest();
    
    $nums = ["306999999999", /*"306999999998", "306999999997", ...*/];
    
    $message = new MessageContent();
    $message->setText("Hello there!");
    $message->setSenderId("Apifon");
    
    $smsRequest->setStrSubscribers($nums);
    $smsRequest->setMessage($message);
    
    $response = $smsResource->send($smsRequest);
    var_dump($response);
    
    Mookee.AddCredentials("sms", "Your_SMS_Token", "Your_SMS_Secret_Key");
    Mookee.SetActiveCredential("sms");
    
    List<string> numbers = new List<string>();
    numbers.Add("306999999999");
    //numbers.Add("306999999998");
    //numbers.Add("306999999997");
    
    SMSResource smsResource = new SMSResource();
    SmsRequest smsRequest = new SmsRequest();
    
    MessageContent message = new MessageContent();
    message.Text = "Hello There!";
    message.SenderId = "Apifon";
    
    smsRequest.AddStrSubscribers(numbers);
    smsRequest.Message = message;
    
    GatewayResponse response = smsResource.Send(smsRequest);
    PrintOutput(response);
    
    import Apifon.Mookee as mookee
    from Apifon.Model.MessageContent import MessageContent
    from Apifon.Model.SmsRequest import SmsRequest
    from Apifon.Resource.SMSResource import SMSResource
    
    Mookee = mookee.Mookee.get_instance()
    
    Mookee.add_credentials("sms", "Your_SMS_Token", "Your_SMS_Secret_Key")
    Mookee.set_active_credential("sms")
    
    smsResource = SMSResource()
    smsRequest = SmsRequest()
    
    nums = ["306999999999"]
    
    msgContent = MessageContent()
    msgContent.text = "Hello There!"
    msgContent.sender_id = "Apifon"
    
    smsRequest.add_str_subscribers(nums)
    smsRequest.message = msgContent
    
    response = smsResource.send(smsRequest)
    print_json(response)
    
    var Mookee = require('./Apifon/Mookee');
    
    const SMSResource = require('./Apifon/Resource/SMSResource');
    const SmsRequest = require('./Apifon/Model/SmsRequest');
    const MessageContent = require('./Apifon/Model/MessageContent');
    
    Mookee.getInstance();
    Mookee.addCredentials("sms", "Your_SMS_Token", "Your_SMS_Secret_Key");
    Mookee.setActiveCredential("sms");
    
    var nums = ["306999999999"/*, "306999999998", "306999999997", ...*/];
    
    var smsResource = new SMSResource();
    var smsRequest = new SmsRequest();
    
    var msgContent = new MessageContent();
    msgContent.text = "Hello There!";
    msgContent.sender_id = "Apifon";
    
    smsRequest.addStrSubscribers(nums);
    smsRequest.message = msgContent;
    
    var response = smsResource.send(smsRequest);
    printJson(response);
    

    Viber Example

    Mookee.addCredentials("viber", "Your_Viber_Token", "Your_Viber_Secret_Key");
    Mookee.setActiveCredential("viber");
    
    String[] nums = {"306999999999"/*, "306999999998", "306999999997", ...*/};
    ArrayList<String> numbers = new ArrayList();
    numbers.addAll(Arrays.asList(nums));
    
    IMChannel imChannel = new IMChannel();
    ImRequest imRequest = new ImRequest();
    
    IMAction imAction = new IMAction();
    imAction.setTitle("Renew now!");
    imAction.setTargetUrl("https://www.apifon.com");
    
    imChannel.setSenderId("Mookee");
    imChannel.setText("50% discount on our membership fee if you renew your subscription today!");
    imChannel.addImage("http://assets.apifon.com/images/boy_girl.jpg");
    imChannel.addAction(imAction);
    
    imRequest.addStrSubscribers(numbers);
    imRequest.addImChannel(imChannel);
    
    GatewayResponse response = imResource.send(imRequest);
    printJson(response);
    
    Class Can Be Added To Description
    IMAction IMChannel Represents an Action for an IM Request.
    IMChannel ImRequest Represents a Channel for an IM Request.
    LandingProperties SubscriberInformation Represents a Landing Page for an SMS/IM Request.
    MessageContent SmsRequest/ImRequest Represents a Message for an SMS/IM Request.
    SubscriberInformation SmsRequest/ImRequest Represents a Subscriber for an SMS/IM Request.
    <?php
    
    use Apifon\Mookee;
    use Apifon\Model\IMChannel;
    use Apifon\Model\ImRequest;
    use Apifon\Model\IMAction;
    use Apifon\Resource\IMResource;
    
    require_once ("./Apifon/Mookee.php");
    require_once ("./Apifon/Model/IMChannel.php");
    require_once ("./Apifon/Model/IRequest.php");
    require_once ("./Apifon/Model/SubscribersViewRequest.php");
    require_once ("./Apifon/Model/ImRequest.php");
    require_once ("./Apifon/Model/IMAction.php");
    require_once ("./Apifon/Model/SubscriberInformation.php");
    require_once ("./Apifon/Response/GatewayResponse.php");
    require_once ("./Apifon/Security/Hmac.php");
    require_once ("./Apifon/Resource/AbstractResource.php");
    require_once ("./Apifon/Resource/IMResource.php");
    
    Mookee::addCredentials("viber","Your_Viber_Token", "Your_Viber_Secret_Key");
    Mookee::setActiveCredential("viber");
    
    $imResource = new IMResource();
    
    $nums = ["306999999999", /*"306999999998", "306999999997", ...*/];
    
    $imChannel = new IMChannel();
    $imRequest = new ImRequest();
    
    $imAction = new IMAction();
    $imAction->setTitle("Renew now!");
    $imAction->setTargetUrl("https://www.apifon.com");
    
    $imChannel->setText("50% discount on our membership fee if you renew your subscription today!");
    $imChannel->setSenderId("Mookee");
    $imChannel->addImage("http://assets.apifon.com/images/boy_girl.jpg");
    $imChannel->addAction($imAction);
    
    $imRequest->setStrSubscribers($nums);
    $imRequest->addImChannel($imChannel);
    
    $response = $imResource->send($imRequest);
    var_dump($response);
    
    Mookee.AddCredentials("viber", "Your_Viber_Token", "Your_Viber_Secret_Key");
    Mookee.SetActiveCredential("viber");
    
    List<string> numbers = new List<string>();
    numbers.Add("306999999999");
    //numbers.Add("306999999998");
    //numbers.Add("306999999997");
    
    ImRequest imRequest = new ImRequest();
    
    IMAction imAction = new IMAction();
    imAction.Title = "Renew now!";
    imAction.TargetUrl = "https://www.apifon.com";
    
    IMChannel imChannel = new IMChannel();
    imChannel.Text = "50% discount on our membership fee if you renew your subscription today!";
    imChannel.SenderId = "Mookee";
    imChannel.AddImage("http://assets.apifon.com/images/boy_girl.jpg");
    imChannel.AddAction(imAction);
    
    imRequest.AddStrSubscribers(numbers);
    imRequest.AddImChannel(imChannel);
    
    response = imResource.Send(imRequest);
    PrintJson(response);
    
    import Apifon.Mookee as mookee
    from Apifon.Model.IMChannel import IMChannel
    from Apifon.Model.ImRequest import ImRequest
    from Apifon.Model.IMAction import IMAction
    from Apifon.Resource.IMResource import IMResource
    
    Mookee = mookee.Mookee.get_instance()
    
    Mookee.add_credentials("viber", "Your_Viber_Token", "Your_Viber_Secret_Key")
    Mookee.set_active_credential("viber")
    
    imResource = IMResource()
    
    nums = ["306999999999"]
    
    imChannel = IMChannel()
    imRequest = ImRequest()
    
    imAction = IMAction()
    imAction.title = "Renew now!"
    imAction.target_url = "https://www.apifon.com"
    
    imChannel.text = "50% discount on our membership fee if you renew your subscription today!"
    imChannel.sender_id = "Mookee"
    imChannel.add_image("http://assets.apifon.com/images/boy_girl.jpg")
    imChannel.add_action(imAction)
    
    imRequest.add_str_subscribers(nums)
    imRequest.add_im_channel(imChannel)
    
    response = imResource.send(imRequest)
    print_json(response)
    
    var Mookee = require('./Apifon/Mookee');
    
    const ImRequest = require('./Apifon/Model/ImRequest');
    const IMChannel = require('./Apifon/Model/IMChannel');
    const IMAction = require('./Apifon/Model/IMAction');
    const IMResource = require('./Apifon/Resource/IMResource');
    
    Mookee.getInstance();
    Mookee.addCredentials("viber", "Your_Viber_Token", "Your_Viber_Secret_Key");
    Mookee.setActiveCredential("viber");
    
    var imResource = new IMResource();
    
    var nums = ["306999999999"/*, "306999999998", "306999999997", ...*/];
    
    var imRequest = new ImRequest();
    var imChannel = new IMChannel();
    
    var imAction = new IMAction();
    imAction.title = "Renew now!";
    imAction.target_url = "https://www.apifon.com";
    
    imChannel.text = "50% discount on our membership fee if you renew your subscription today!";
    imChannel.sender_id = "Mookee";
    imChannel.addImage("http://assets.apifon.com/images/boy_girl.jpg");
    imChannel.addAction(imAction);
    
    imRequest.addStrSubscribers(nums);
    imRequest.addChannel(imChannel);
    
    var response = imResource.send(imRequest);
    printJson(response);
    

    Viber Example With Failover To SMS

    Mookee.addCredentials("viber", "Your_Viber_Token", "Your_Viber_Secret_Key");
    Mookee.setActiveCredential("viber");
    
    String[] nums = {"306999999999"/*, "306999999998", "306999999997", ...*/};
    ArrayList<String> numbers = new ArrayList();
    numbers.addAll(Arrays.asList(nums));
    
    IMChannel imChannel = new IMChannel();
    ImRequest imRequest = new ImRequest();
    
    IMAction imAction = new IMAction();
    imAction.setTitle("Renew now!");
    imAction.setTargetUrl("https://www.apifon.com");
    
    imChannel.setSenderId("Mookee");
    imChannel.setText("50% discount on our membership fee if you renew your subscription today!");
    imChannel.addImage("http://assets.apifon.com/images/boy_girl.jpg");
    imChannel.addAction(imAction);
    
    MessageContent msgContent = new MessageContent();
    msgContent.setText("Hello There!");
    msgContent.setSenderId("Apifon");
    
    imRequest.addStrSubscribers(numbers);
    imRequest.setMessage(msgContent);
    imRequest.addImChannel(imChannel);
    
    GatewayResponse response = imResource.send(imRequest);
    printJson(response);
    
    <?php
    
    use Apifon\Mookee;
    use Apifon\Model\IMChannel;
    use Apifon\Model\ImRequest;
    use Apifon\Model\IMAction;
    use Apifon\Model\MessageContent;
    use Apifon\Resource\IMResource;
    
    require_once ("./Apifon/Mookee.php");
    require_once ("./Apifon/Model/IMChannel.php");
    require_once ("./Apifon/Model/IRequest.php");
    require_once ("./Apifon/Model/SubscribersViewRequest.php");
    require_once ("./Apifon/Model/ImRequest.php");
    require_once ("./Apifon/Model/IMAction.php");
    require_once ("./Apifon/Model/SubscriberInformation.php");
    require_once ("./Apifon/Model/MessageContent.php");
    require_once ("./Apifon/Response/GatewayResponse.php");
    require_once ("./Apifon/Security/Hmac.php");
    require_once ("./Apifon/Resource/AbstractResource.php");
    require_once ("./Apifon/Resource/IMResource.php");
    
    Mookee::addCredentials("viber","Your_Viber_Token", "Your_Viber_Secret_Key");
    Mookee::setActiveCredential("viber");
    
    $imResource = new IMResource();
    
    $nums = ["306999999999", /*"306999999998", "306999999997", ...*/];
    
    $imChannel = new IMChannel();
    $imRequest = new ImRequest();
    
    $imAction = new IMAction();
    $imAction->setTitle("Renew now!");
    $imAction->setTargetUrl("https://www.apifon.com");
    
    $imChannel->setText("50% discount on our membership fee if you renew your subscription today!");
    $imChannel->setSenderId("Mookee");
    $imChannel->addImage("http://assets.apifon.com/images/boy_girl.jpg");
    $imChannel->addAction($imAction);
    
    $message = new MessageContent();
    $message->setText("Hello there!");
    $message->setSenderId("Apifon");
    
    $imRequest->setStrSubscribers($nums);
    $imRequest->setMessage($message);
    $imRequest->addImChannel($imChannel);
    
    $response = $imResource->send($imRequest);
    var_dump($response);
    
    Mookee.AddCredentials("viber", "Your_Viber_Token", "Your_Viber_Secret_Key");
    Mookee.SetActiveCredential("viber");
    
    List<string> numbers = new List<string>();
    numbers.Add("306999999999");
    //numbers.Add("306999999998");
    //numbers.Add("306999999997");
    
    ImRequest imRequest = new ImRequest();
    
    IMAction imAction = new IMAction();
    imAction.Title = "Renew now!";
    imAction.TargetUrl = "https://www.apifon.com";
    
    IMChannel imChannel = new IMChannel();
    imChannel.Text = "50% discount on our membership fee if you renew your subscription today!";
    imChannel.SenderId = "Mookee";
    imChannel.AddImage("http://assets.apifon.com/images/boy_girl.jpg");
    imChannel.AddAction(imAction);
    
    MessageContent msgContent = new MessageContent();
    msgContent.Text = "Hello There!";
    msgContent.SenderId = "Apifon";
    
    imRequest.AddStrSubscribers(numbers);
    imRequest.MessageContent = msgContent;
    imRequest.AddImChannel(imChannel);
    
    response = imResource.Send(imRequest);
    PrintJson(response);
    
    import Apifon.Mookee as mookee
    from Apifon.Model.IMChannel import IMChannel
    from Apifon.Model.ImRequest import ImRequest
    from Apifon.Model.IMAction import IMAction
    from Apifon.Model.MessageContent import MessageContent
    from Apifon.Resource.IMResource import IMResource
    
    Mookee = mookee.Mookee.get_instance()
    
    Mookee.add_credentials("viber", "Your_Viber_Token", "Your_Viber_Secret_Key")
    Mookee.set_active_credential("viber")
    
    imResource = IMResource()
    
    nums = ["306999999999"]
    
    imChannel = IMChannel()
    imRequest = ImRequest()
    
    imAction = IMAction()
    imAction.title = "Renew now!"
    imAction.target_url = "https://www.apifon.com"
    
    imChannel.text = "50% discount on our membership fee if you renew your subscription today!"
    imChannel.sender_id = "Mookee"
    imChannel.add_image("http://assets.apifon.com/images/boy_girl.jpg")
    imChannel.add_action(imAction)
    
    msgContent = MessageContent()
    msgContent.text = "Hello There!"
    msgContent.sender_id = "Apifon"
    
    imRequest.add_str_subscribers(nums)
    imRequest.message = msgContent
    imRequest.add_im_channel(imChannel)
    
    response = imResource.send(imRequest)
    print_json(response)
    
    var Mookee = require('./Apifon/Mookee');
    
    const ImRequest = require('./Apifon/Model/ImRequest');
    const IMChannel = require('./Apifon/Model/IMChannel');
    const IMAction = require('./Apifon/Model/IMAction');
    const MessageContent = require('./Apifon/Model/MessageContent');
    const IMResource = require('./Apifon/Resource/IMResource');
    
    Mookee.getInstance();
    Mookee.addCredentials("viber", "Your_Viber_Token", "Your_Viber_Secret_Key");
    Mookee.setActiveCredential("viber");
    
    var imResource = new IMResource();
    
    var nums = ["306999999999"/*, "306999999998", "306999999997", ...*/];
    
    var imRequest = new ImRequest();
    var imChannel = new IMChannel();
    
    var imAction = new IMAction();
    imAction.title = "Renew now!";
    imAction.target_url = "https://www.apifon.com";
    
    imChannel.text = "50% discount on our membership fee if you renew your subscription today!";
    imChannel.sender_id = "Mookee";
    imChannel.addImage("http://assets.apifon.com/images/boy_girl.jpg");
    imChannel.addAction(imAction);
    
    var msgContent = new MessageContent();
    msgContent.text = "Hello There!";
    msgContent.sender_id = "Apifon";
    
    imRequest.addStrSubscribers(nums);
    imRequest.message = msgContent;
    imRequest.addChannel(imChannel);
    
    var response = imResource.send(imRequest);
    printJson(response);
    

    Viber Example With Landing Page

    Mookee.addCredentials("viber", "Your_Viber_Token", "Your_Viber_Secret_Key");
    Mookee.setActiveCredential("viber");
    
    String[] names = {"John", "George", "Alex", "Helen"};
    String[] nums = {"306999999999"/*, "306999999998", "306999999997", ...*/};
    ArrayList<String> numbers = new ArrayList();
    numbers.addAll(Arrays.asList(nums));
    
    IMChannel imChannel = new IMChannel();
    ImRequest imRequest = new ImRequest();
    
    IMAction imAction = new IMAction();
    imAction.setTitle("Renew now!");
    imAction.setTargetUrl("{apifon_lp}");
    
    imChannel.setSenderId("Mookee");
    imChannel.setText("{name}! 50% discount on our membership fee if you renew your subscription today!");
    imChannel.addImage("http://assets.apifon.com/images/boy_girl.jpg");
    imChannel.addAction(imAction);
    
    ArrayList<SubscriberInformation> subscribers = new ArrayList();
    for (String num : numbers) {
        subscribers.add(new SubscriberInformation());
        subscribers.get(subscribers.size() - 1).setNumber(num);
        subscribers.get(subscribers.size() - 1).setPropertyToParam("name", names[subscribers.size() - 1]);
    
        LandingProperties lp = new LandingProperties();
        lp.setUrl("https://mookee.apifon.com/user/login/");
        lp.addData("name", names[subscribers.size() - 1]);
        lp.setRedirect(true);
    
        subscribers.get(subscribers.size() - 1).setLandingPage(lp);
    }
    
    imRequest.setSubscribers(subscribers);
    imRequest.addImChannel(imChannel);
    
    GatewayResponse response = imResource.send(imRequest);
    printJson(response);
    
    <?php
    
    use Apifon\Mookee;
    use Apifon\Model\IMChannel;
    use Apifon\Model\ImRequest;
    use Apifon\Model\IMAction;
    use Apifon\Model\LandingProperties;
    use Apifon\Model\SubscriberInformation;
    use Apifon\Resource\IMResource;
    
    require_once ("./Apifon/Mookee.php");
    require_once ("./Apifon/Model/IMChannel.php");
    require_once ("./Apifon/Model/IRequest.php");
    require_once ("./Apifon/Model/SubscribersViewRequest.php");
    require_once ("./Apifon/Model/ImRequest.php");
    require_once ("./Apifon/Model/IMAction.php");
    require_once ("./Apifon/Model/SubscriberInformation.php");
    require_once ("./Apifon/Model/LandingProperties.php");
    require_once ("./Apifon/Response/GatewayResponse.php");
    require_once ("./Apifon/Security/Hmac.php");
    require_once ("./Apifon/Resource/AbstractResource.php");
    require_once ("./Apifon/Resource/IMResource.php");
    
    Mookee::addCredentials("viber","Your_Viber_Token", "Your_Viber_Secret_Key");
    Mookee::setActiveCredential("viber");
    
    $imResource = new IMResource();
    
    $names = ["John", "Jim", "Alex", "Helen"];
    $nums = ["306999999999", /*"306999999998", "306999999997", ...*/];
    
    $imChannel = new IMChannel();
    $imRequest = new ImRequest();
    
    $imAction = new IMAction();
    $imAction->setTitle("Renew now!");
    $imAction->setTargetUrl("{apifon_lp}");
    
    $imChannel->setSenderId("Mookee");
    $imChannel->setText("{name}! 50% discount on our membership fee if you renew your subscription today!");
    $imChannel->addImage("http://assets.apifon.com/images/boy_girl.jpg");
    $imChannel->addAction($imAction);
    
    $subscribers = array();
    for ($i=0;$i<sizeof($nums);$i++){
        $lp = new LandingProperties();
        $lp->setUrl("https://mookee.apifon.com/user/login/");
        $lp->addData("name", $names[$i]);
        $lp->setRedirect(true);
    
        $sub = new SubscriberInformation();
        $sub->setNumber($nums[$i]);
        $sub->setCustomId("222");
        $sub->addParams("name", $names[$i]);
        $sub->setLandingPage($lp);
        $subscribers[] = $sub;
    }
    
    $imRequest->setSubscribers($subscribers);
    $imRequest->addImChannel($imChannel);
    
    $response = $imResource->send($imRequest);
    var_dump($response);
    
    Mookee.AddCredentials("viber", "Your_Viber_Token", "Your_Viber_Secret_Key");
    Mookee.SetActiveCredential("viber");
    
    string[] names = { "John", "George", "Alex", "Helen" };
    List<string> numbers = new List<string>();
    numbers.Add("306999999999");
    //numbers.Add("306999999998");
    //numbers.Add("306999999997");
    
    ImRequest imRequest = new ImRequest();
    
    IMAction imAction = new IMAction();
    imAction.Title = "Renew now!";
    imAction.TargetUrl = "{apifon_lp}";
    
    IMChannel imChannel = new IMChannel();
    imChannel.Text = "{name}! 50% discount on our membership fee if you renew your subscription today!";
    imChannel.SenderId = "Mookee";
    imChannel.AddImage("http://assets.apifon.com/images/boy_girl.jpg");
    imChannel.AddAction(imAction);
    
    List<SubscriberInformation> subscribers = new List<SubscriberInformation>();
    foreach (String num in numbers)
    {
        SubscriberInformation sub = new SubscriberInformation();
        sub.Number = num;
        sub.AddParams("name", names[subscribers.Count]);
    
        LandingProperties lp = new LandingProperties();
        lp.Url = "https://mookee.apifon.com/user/login/";
        lp.AddData("name", names[subscribers.Count]);
        lp.Redirect = true;
    
        sub.SetLandingPage(lp);
        subscribers.Add(sub);
    }
    
    imRequest.AddSubscribers(subscribers);
    imRequest.AddImChannel(imChannel);
    
    response = imResource.Send(imRequest);
    PrintJson(response);
    
    import Apifon.Mookee as mookee
    from Apifon.Model.IMChannel import IMChannel
    from Apifon.Model.ImRequest import ImRequest
    from Apifon.Model.IMAction import IMAction
    from Apifon.Model.SubscriberInformation import SubscriberInformation
    from Apifon.Model.LandingProperties import LandingProperties
    from Apifon.Resource.IMResource import IMResource
    
    Mookee = mookee.Mookee.get_instance()
    
    Mookee.add_credentials("viber", "Your_Viber_Token", "Your_Viber_Secret_Key")
    Mookee.set_active_credential("viber")
    
    imResource = IMResource()
    
    names = ["John", "George", "Alex", "Helen"]
    nums = ["306999999999"]
    
    imChannel = IMChannel()
    imRequest = ImRequest()
    
    imAction = IMAction()
    imAction.title = "Renew now!"
    imAction.target_url = "https://www.apifon.com"
    
    imChannel.text = "{name}! 50% discount on our membership fee if you renew your subscription today!"
    imChannel.sender_id = "Mookee"
    imChannel.add_image("http://assets.apifon.com/images/boy_girl.jpg")
    imChannel.add_action(imAction)
    
    subscribers = list()
    for num in nums:
        sub = SubscriberInformation()
        sub.number = num
        sub.add_params("name", names[len(subscribers)])
    
        lp = LandingProperties()
        lp.url = "https://mookee.apifon.com/user/login/"
        lp.add_data("name", names[len(subscribers)])
        lp.redirect = True
        sub.set_landing_page(lp)
    
        subscribers.append(sub)
    
    imRequest.add_subscribers(subscribers)
    imRequest.add_im_channel(imChannel)
    
    response = imResource.send(imRequest)
    print_json(response)
    
    var Mookee = require('./Apifon/Mookee');
    
    const ImRequest = require('./Apifon/Model/ImRequest');
    const IMChannel = require('./Apifon/Model/IMChannel');
    const IMAction = require('./Apifon/Model/IMAction');
    const SubscriberInformation = require('./Apifon/Model/SubscriberInformation');
    const LandingProperties = require('./Apifon/Model/LandingProperties');
    const IMResource = require('./Apifon/Resource/IMResource');
    
    Mookee.getInstance();
    Mookee.addCredentials("viber", "Your_Viber_Token", "Your_Viber_Secret_Key");
    Mookee.setActiveCredential("viber");
    
    var imResource = new IMResource();
    
    var names = ["John", "George", "Alex", "Helen"];
    var nums = ["306999999999"/*, "306999999998", "306999999997", ...*/];
    
    var imRequest = new ImRequest();
    var imChannel = new IMChannel();
    
    var imAction = new IMAction();
    imAction.title = "Renew now!";
    imAction.target_url = "{apifon_lp}";
    
    imChannel.sender_id = "Mookee";
    imChannel.text = "{name}! 50% discount on our membership fee if you renew your subscription today!";
    imChannel.addImage("http://assets.apifon.com/images/boy_girl.jpg");
    imChannel.addAction(imAction);
    
    var subscribers = [];
    for(var i = 0; i < nums.length; i++){
        var sub = new SubscriberInformation();
        sub.number = nums[i];
        sub.addParam("name", names[i])
    
        var lp = new LandingProperties();
        lp.url = "https://mookee.apifon.com/user/login/";
        lp.addData("name", names[subscribers.length]);
        lp.redirect = true;
    
        sub.setLandingPage(lp);
        subscribers.push(sub);
    }
    
    imRequest.addSubscribers(subscribers);
    imRequest.addChannel(imChannel);
    
    var response = imResource.send(imRequest);
    printJson(response);
    

    All of the SDKs were build so they are easy to use.

    OAuth2

    First off you need to retrieve a Bearer token from the Identity Service. For that you need an instance of the OAuthConfiguration which will be passed to the Mookee instance in order to retrieve your credentials. After receiving a Bearer Token you set the Mookee instance to OAuth2 mode. All subsequent requests using Mookee will be executed using your OAuth2 Bearer Token.

    HMAC

    The first thing you have to do is to add your credentials to the Mookee class. Mookee stores your credentials using a specific Key. As you can store multiple credentials, you have to specify the Active Credential Key, a.k.a. the credential that you want to use to send your request.

    Requests

    Class Parent Description
    IRequest ----- An abstract implementation of a Request.
    SubscriberViewRequest IRequst An abstract implementation of a Request that contains subscribers.
    RemoveRequest IRequest Represents a Deletion Request.
    SmsRequest SubscriberViewRequest Represents an SMS Request.
    ImRequest SubscriberViewRequest Represents an IM Request.

    Request properties

    Class Can Be Added To Description
    IMAction IMChannel Represents an Action for an IM Request.
    IMChannel ImRequest Represents a Channel for an IM Request.
    LandingProperties SubscriberInformation Represents a Landing Page for an SMS/IM Request.
    MessageContent SmsRequest/ImRequest Represents a Message for an SMS/IM Request.
    SubscriberInformation SmsRequest/ImRequest Represents a Subscriber for an SMS/IM Request.

    Resources

    Class Parent Description
    AbstractResource ----- An abstract implementation of a Resource.
    SMSResource AbstractResource An SMSResource is responsible for sending Send and Remove SMS Requests.
    IMResource AbstractResource An IMResource is responsible for sending Send and Remove IM Requests.
    BalanceResource AbstractResource A BalanceResource is responsible for sending Balance Requests.

    Responses

    Class Parent Description
    GatewayResponse ----- Represents the Response of our Request (SMS or IM).
    BalanceResponse ----- Represents the Response of our Balance Request.

    Mookee

    Method Parameters Description
    getInstance void Returns a reference to the Singleton Mookee instance.
    addCredentials key, token, secretKey Adds your credential in a map, using key as a keyIndicator.
    setActiveCredential key Defines the credentials that are to be used in the upcoming Requests.
    setStaging flag Set to true if you want your requests to be send to the Staging API.

    Download

    Please choose the file you want to download (.tar.gz or .zip).

    Java

    The JavaSDK project needs the following dependencies to run: gson-2.7.jar
    httpclient-4.5.2.jar
    commons-codec-1.9.jar
    commons-logging-1.2.jar
    httpcore-4.4.4.jar

    Building the JavaSDK will produce three .jar files: apifon-sdk-java.jar a library without the project dependencies.
    apifon-sdk-java-jar-with-dependencies.jar a library with the project dependencies.
    apifon-sdk-java-javadoc.jar contains the SDK javadoc.

    In order to include the apifon Java SDK to your own project you have to keep in mind that it requires the use of the dependencies mentioned above. This is why the project produces a .jar file containing those dependencies. In case your project has already included them, you can use the .jar file that does not contain the dependencies above, other ways you need to use the one containing this dependencies.

    apifon-sdk-java.tar.gz

    apifon-sdk-java.zip

    Php

    The PhpSDK also contains a WebServer (WebServer.php) where you can run your examples and test them. Running WebServer.php will display a web page with three TextAreas. The first will contain your Request Body, the second your Response Body and the third one your Callback Response. You may set your callback URL to http://yourserver/apifon-sdk-php/CallbackHandling/callback.php and your callback responses will be stored in the apifon-sdk-php/CallbackHandling/callback.txt text file. WebServer.php examples will clean the callback.txt file before receiving a new one.

    apifon-sdk-php.tar.gz

    apifon-sdk-php.zip

    C#

    apifon-sdk-csharp.tar.gz

    apifon-sdk-csharp.zip

    Python3

    apifon-sdk-python.tar.gz

    apifon-sdk-python.zip

    NodeJS

    apifon-sdk-nodejs.tar.gz

    apifon-sdk-nodejs.zip