Kavenegar

Kavenegar Webservice

Kavenegar RESTful API Document

If you need to future information about API document Please visit RESTful Document

First of all, You need to make an account on Kavenegar from Kaveneagr webpage

After that you just need to pick API-KEY up from My Account section.

Here You can download the Java SDK or just pull it.

Anyway there is good tutorial about Pull request


Contributing

Ongoing kavenegar development takes place in the open on GitHub. We encourage pull requests and issues to discuss problems with and changes that could be made to the content. We hope that keeping our process in the best way and what changes will be coming in future kavenegar .


Dotnet SDK

Installation

For installing just follow these steps:

Fisrt Method :

  • If you have nuget you can go to next part but if you don't have it you can download and install it here

  • From tools section Library Package Manager select Package Manager Console .

  • execute Install-Package Kavenegar in the console.

  • Now Kavenegar.dll package is acessable in Solution explorer

Second method

  • Manually Here Downlaod SDk

Download SDk

Dowload sample code


Usage

  • From Solution explorer right click on References and form new menu select Add Referencethen choose Kavenegar.dll .

Well, There is an example to Send SMS by C#.


try
{
    Kavenegar.KavenegarApi api = new Kavenegar.KavenegarApi("Your Api Key");
    var result = api.Send("SenderLine", "Your Receptor", "Kaveh specialized Web service");
    foreach (var r in result){
      Console.Write("r.Messageid.ToString()");
  }
}
catch (Kavenegar.Exceptions.ApiException ex) 
{
    //In case that error throw 200 
    Console.Write("Message : " + ex.Message);
}
catch (Kavenegar.Exceptions.HttpException ex) 
{
//in case that there is any problem to connect to webservie  this error thow
    Console.Write("Message : " + ex.Message);
}

Node

Installation

For installing Kavenegar vai Npm use this command

npm install kavenegar 

If you don't have npm you can easily install it from npm website

Usage

Well, There is two example to Send SMS by node below.


var Kavenegar = require('kavenegar');
var api = Kavenegar.KavenegarApi({
    apikey: ''
});
api.Send({
        message: "Kaveh specialized Web service  ",
        sender: "10004346",
        receptor: "{Your API Key}"
    },
    function(response, status) {
        console.log(response);
        console.log(status);
    });


var Kavenegar = require('kavenegar');
var api = Kavenegar.KavenegarApi({
    apikey: '{Your API Key}'
});
api.VerifyLookup({
    receptor: "{Your Phone Number} ",
    token: "852596",
    template: "registerverify"
}, function(response, status) {
    console.log(response);
    console.log(status);
});


Java

Installation

To get a Git project into your build:

Add it depend on what you are using :

gradle

Step 1 : Add the JitPack repository to your build file

allprojects {
        repositories {
            ...
            maven { url 'https://jitpack.io' }
        }
    }

Step 2 : Add the dependency

dependencies {
        compile 'com.github.User:Repo:Tag'
    }

maven

Step 1 : Add the JitPack repository to your build file

<repositories>
        <repository>
            <id>jitpack.io</id>
            <url>https://jitpack.io</url>
        </repository>
    </repositories>

Step 2 : Add the dependency

<dependency>
        <groupId>com.github.User</groupId>
        <artifactId>Repo</artifactId>
        <version>Tag</version>
    </dependency>

sbt

Step 1

Add the JitPack repository to your build file

    resolvers += "jitpack" at "https://jitpack.io"

Step 2

Add the dependency

    libraryDependencies += "com.github.User" % "Repo" % "Tag"

leiningen

Step 1

Add the JitPack repository to your build file

    :repositories [["jitpack" "https://jitpack.io"]]

    }

Step 2

Add the dependency

    :dependencies [[com.github.User/Repo "Tag"]]

Usage

Well,You can see an example of sending SMS through JAVA below .


try {
     KavenegarApi  api= new KavenegarApi("");
      SendResult Result = api.Send("SenderLine", "Your Receptor", "Kaveh specialized Web service ");
}
catch (HttpException ex)
{//In case that error throw 200 

  System.out.print("HttpException  : " + ex.getMessage());
}
catch (ApiException ex)
{ //in case that there is any problem to connect to webservie  this error thow

   System.out.print("ApiException : " + ex.getMessage());
}


PHP

Installation

Use in these ways :

composer require kavenegar/php

or add

"kavenegar/php": "*"

And run following command to download extension using composer

$ composer update

Usage

Well, There is an example to Send SMS by PHP.

require __DIR__ . '/vendor/autoload.php';

try{
    $api = new \Kavenegar\KavenegarApi({ "{API Key}" });
    $sender = "10004346";
    $message = "Kaveh specialized Web service  ";
    $receptor = array("{Your Phone Number}");
    $result = $api->Send($sender,$receptor,$message);
    if($result){
        foreach($result as $r){
            echo "messageid = $r->messageid";
            echo "message = $r->message";
            echo "status = $r->status";
            echo "statustext = $r->statustext";
            echo "sender = $r->sender";
            echo "receptor = $r->receptor";
            echo "date = $r->date";
            echo "cost = $r->cost";
        }       
    }
}
catch(\Kavenegar\Exceptions\ApiException $e){
//In case that error throw 200 
    echo $e->errorMessage();
}
catch(\Kavenegar\Exceptions\HttpException $e){
//in case that there is any problem to connect to webservie  this error thow
    echo $e->errorMessage();
}



Python

Installation

Usage

Well, There is an example to Send SMS by Python below.

#!/usr/bin/env python
from kavenegar import *
try:
    import json
except ImportError:
    import simplejson as json

try:
    api = KavenegarAPI('{Your APIKey}')
    params = {
        'sender': '10004346',
        'receptor': '{Your Phone Number}',
        'message': 'Kaveh specialized Web service '
    }   
    response = api.sms_send(params)
    print str(response)
except APIException,e: 
    print str(e)
except HTTPException,e: 
    print str(e)


go Build Status

Install it in this way

go get github.com/negah/kavenegar

Usage

Well, There is an example to Send SMS by go below.

package main

import (
  "github.com/negah/kavenegar"
  "log"
  "fmt"
)

func main(){
  // Setup new Client
  // kavenegar.SMS(api_key, sender)
  // sender is your dedicate phone_number in kavenagar. if you dont have one, left it blank but pass ""
  sms := kavenegar.NewSMS("api_key","{Your APi Key}")

  // Send sms
  status, err := sms.Send("{Your Phone Number} ", "Hello my friend ")

  if err != nil {
    log.Printf("Response status code: %d", status)
    log.Fatal(err)
  } else {
    fmt.Printf("SMS sent successfully.")
  }
}


Ruby

Installation

Usage

Add this line to your application's Gemfile:

gem 'kave'

And then execute:

$ bundle install

Or install it yourself(localy) as:

$ gem install kave

And create init file on config directory(kave.rb):

Kave.configure do |config|
  config.wsdl ='http://api.kavenegar.com/soap/v1.asmx?WSDL'
  config.sender  = 'number'

Well, There is an example to Send SMS by Ruby.

 request=Kave::SendRequestSimple.new({

    message: 'سلام عزیز :)',
    mobile: 'Your Phone Number ',
    #optional
    unixdate: by default 0 ,
    msgmode: by default 1
})

res=request.call
render :text=>{status_message_only_farsi: res.statusmessage,status_code: res.status}

Elixir


Installation

If available in Hex, the package can be installed as:

  1. Add kavenegar to your list of dependencies in mix.exs:

    def deps do
      [{:kavenegar, "~> 0.0.1"}]
    end
    
  2. Ensure kavenegar is started before your application:

    def application do
      [applications: [:kavenegar]]
    end
    

Usage

Well, There is an example to Send SMS by Elixir.

Kavenegar.send %{receptor: '{Your Phone Number}', message: "this is a sample text"}

will return:

%{"entries" => [%{"cost" => 130, "date" => 1466091791,
     "message" => "this is a sample text", "messageid" => 999999999,
     "receptor" => "{Your Phone Number}", "sender" => "10001000010000", "status" => 1,
     "statustext" => "In sending list"}],
  "return" => %{"message" => "Confirm", "status" => 200}}

Laravel


Requirements

Laravel 4 or 5.

Installation

Install it this way :

composer require kavenegar/laravel

Laravel 5

Add the Kavenegar\Laravel\ServiceProvider provider to the providers array in config/app.php:

'providers' => [
  ...
  Kavenegar\Laravel\ServiceProvider::class,
],

Then add the facade to your aliases array:

'aliases' => [
  ...
  'Kavenegar' => Kavenegar\Laravel\Facade::class,
],

Finally, publish the config file with php artisan vendor:publish. You'll find it at config/kavenegar.php.

Laravel 4

Add the Kavenegar\Laravel\ServiceProvider provider to the providers array in app/config.php:

'providers' => [
  ...
  'Kavenegar\Laravel\ServiceProvider',
],

Then add the facade to your aliases array:

'aliases' => [
  ...
  'Kavenegar' => Kavenegar\Laravel\Facade',
],

Finally, publish the config file with php artisan config:publish kavenegar/laravel. You'll find the config file at app/config/packages/kavenegar/laravel/config.php.

Usage

Well, There is an example to Send SMS by Laravel below.


use Kavenegar as api;
try{
    $sender = "10004346";
    $message = "Kaveh specialized Web service ";
    $receptor = array("{Your Phone Number}");
    $result = api->Send($sender,$receptor,$message);
    if($result){
        foreach($result as $r){
            echo "messageid = $r->messageid";
            echo "message = $r->message";
            echo "status = $r->status";
            echo "statustext = $r->statustext";
            echo "sender = $r->sender";
            echo "receptor = $r->receptor";
            echo "date = $r->date";
            echo "cost = $r->cost";
        }       
    }
}
catch(\Kavenegar\Exceptions\ApiException $e){
    //In case that error throw 200 
    echo $e->errorMessage();
}
catch(\Kavenegar\Exceptions\HttpException $e){
//in case that there is any problem to connect to webservie  this error thow
    echo $e->errorMessage();
}

yii2

Installation

Install it these ways :

composer require kavenegar/yii2

or add

"kavenegar/yii2": "*"

And run following command to download extension using **composer**:

$ composer update

Configuration

Add the following in your config:

return [
    'components' => [
        'Kavenegar' => [
            'class' => 'Kavenegar\Yii2\Kavenegar',
            'apikey' => '{Your API Key}',
        ],
    ],
];

Usage

Well, There is an example to Send SMS by yii2 below.

try{
    $api = Yii::$app->Kavenegar->KavenegarApi();
    $sender = "10004346";
    $message = "Kaveh specialized Web service ";
    $receptor = array("{Your Phone Number} ");
    $result = $api->Send($sender,$receptor,$message);
    if($result){
        foreach($result as $r){
            echo "messageid = $r->messageid";
            echo "message = $r->message";
            echo "status = $r->status";
            echo "statustext = $r->statustext";
            echo "sender = $r->sender";
            echo "receptor = $r->receptor";
            echo "date = $r->date";
            echo "cost = $r->cost";
        }       
    }
}
catch(\Kavenegar\Exceptions\ApiException $e){
//In case that error throw 200 
    echo $e->errorMessage();
}
catch(\Kavenegar\Exceptions\HttpException $e){
//in case that there is any problem to connect to webservie  this error thow
    echo $e->errorMessage();
}