working on it ...

Filters

Explore Public Snippets

Sort by

Found 1,597 snippets matching: sdk

    public by cghersi @ MailUp API DEV modified Jan 20, 2015  206433  6  6  1

    MailUp REST API - How to subscribe to a particular list several contacts with the "Confirmed Optin" Procedure

    This snippet takes advantage of the MailUp .NET SDK to setup the secure communication towards the server through OAuth2 two leg authentication. You can start digging into the MailUP API world by reading this content: http://help.mailup.com/display/mailupapi/REST+API An instance of MailUpClient class is able to manage one user at a time. A MailU
    public static void SubcribeRecipientsWithDoubleOptin(string clientID, string clientSecret, string username, string password)
    {
        // 1) Setup the MailUp Client:
        MailUpClient client = new MailUpClient(clientID, clientSecret);
        try
        {
            client.RetrieveAccessToken(username, password);
        }
        catch (MailUpException ex)
        {
            Console.WriteLine("Unable to access the service due to " + ex.Message);
            return;
        }
    
        // 2) Subscribe recipients:
        int idList = 1;
        List<ConsoleRecipientItem> recipients = new List<ConsoleRecipientItem>();
        ConsoleRecipientItem recipient1 = new ConsoleRecipientItem()
        {
            Email = "test1@mailup.com",
            Name = "First New Recipient" + DateTime.Now.ToFileTimeUtc(),
            MobileNumber = "3331234567",
            MobilePrefix = "39",
            Fields = new List<ConsoleRecipientDynamicFieldItem>()
            {
                new ConsoleRecipientDynamicFieldItem() { Id = 1, Value = "Name1_" + DateTime.Now.ToFileTimeUtc() },
                new ConsoleRecipientDynamicFieldItem() { Id = 2, Value = "LastName1_" + DateTime.Now.ToFileTimeUtc() }
                //here you can add all the fields you want to add...
            }
        };
        ConsoleRecipientItem recipient2 = new ConsoleRecipientItem()
        {
            Email = "test2@mailup.com",
            Name = "Second New Recipient" + DateTime.Now.ToFileTimeUtc(),
            MobileNumber = "3337654321",
            MobilePrefix = "39",
            Fields = new List<ConsoleRecipientDynamicFieldItem>()
            {
                new ConsoleRecipientDynamicFieldItem() { Id = 1, Value = "Name2_" + DateTime.Now.ToFileTimeUtc() },
                new ConsoleRecipientDynamicFieldItem() { Id = 2, Value = "LastName2_" + DateTime.Now.ToFileTimeUtc() }
                //here you can add all the fields you want to add...
            }
        };
        recipients.Add(recipient1);
        recipients.Add(recipient2);
        int subscriptionResult = 0;
        try
        {
            subscriptionResult = client.AddRecipientsToList(idList, recipients, true);
        }
        catch (Exception ex)
        {
            Console.WriteLine("Cannot perform the operation due to " + ex.Message);
            return;
        }
    
        // 2.1) wait for the end of import task:
        if (subscriptionResult > 0)
        {
            Console.WriteLine("Recipients Import started; import ID:" + subscriptionResult);
    
            //optionally we can check the import status:
            bool completed = false;
            do
            {
                ConsoleImportStatus importStatus = client.CheckImportStatus(subscriptionResult);
                if (importStatus == null)
                {
                    Console.WriteLine("Cannot check the import status for import task #" + subscriptionResult);
                    return;
                }
                completed = importStatus.Completed;
            } while (!completed);
            Console.WriteLine("Recipients Added!");
        }
        else
        {
            Console.WriteLine("An error occurred while adding the recipients.");
            return;
        }
    
        // 3) Retrieve the sendingID of the confirmation email related to the previous task:
        int sendingID = -1;
        try
        {
            sendingID = client.GetSendingIDForImport(subscriptionResult);
        }
        catch (Exception ex)
        {
            Console.WriteLine("Cannot retrieve sending ID due to " + ex.Message);
            return;
        }
        if (sendingID <= 0)
        {
            Console.WriteLine("Cannot retrieve sending ID.");
            return;
        }
    
        // 4) Send the confirmation email:
        EmailSendingItem sendingResult = null;
        try
        {
            sendingResult = client.SendEmailMessage(sendingID);
        }
        catch (Exception ex)
        {
            Console.WriteLine("Cannot send email due to " + ex.Message);
            return;
        }
        if (sendingResult == null)
            Console.WriteLine("Cannot send confirmation email.");
        else
            Console.WriteLine("Confirmation email sent!");
    }
                

    public by mporru @ Amazon_AWS_PHP_API modified Jul 23, 2013  209966  0  5  0

    Amazon AWS - PHP: Upload a File taking it from your server

    This snippet demonstrates how to upload a file to a S3 Bucket, taking it form a your server. In order to use this service you must enable Amazon Simple Storage Service (Amazon S3) in your account. Taken from: http://www.sitepoint.com/getting-started-with-the-aws-php-sdk/
    <?php
    require_once 'sdk.class.php';
    $s3 = new AmazonS3();
    // Create Object is pretty self explanatory:
    // Arg 1: The bucket where your file will be created.
    // Arg 2: The name of your file.
    // Arg 3: An array of Options.
    //        In this case we're specifying the &quot;fileUpload&quot; option (a file on your server)
    //        and the ACL setting to allow this file to be read by anyone.
    $response=$s3->create_object('myBucketName', 'LighthouseNew.jpg', 
    array('fileUpload'=>'./Lighthouse.jpg', 'acl'=>AmazonS3::ACL_PUBLIC));
    // Check if everything is okay.
    if ($response->isOK()) {
    	echo("File uploaded correctly");
    } else {
    	echo("There was an error uploading the file!");
    }
    ?>

    public by DanielOgbuagu modified Jun 28, 2015  201418  1  5  0

    Adding a *.jar file (originating from java-wrapped C++ code) to an SBT project classpath

    I thought using unmanaged dependencies in SBT projects was simply dropping a jar file into the lib directory, until I bought an SDK for a biometric device. Both the C++ and the Java packages were provided. I opted for the Java package, copying the provided jar file and the JNI (*.so) files into the appropriate locations and configuring the ja
    /**
     * In my <code>build.sbt</code> file, I appended a blank line and then the following:
     */
    
    libraryDependencies += "groupID" % "artifactId" % "revision" from "file:///home/Danogbuagu/Projects/biometric-lib/filename.jar"
    
    // where,
    // groupID for example is like: com.zigzagcompany 
    // artifactId for example is like: zigzag
    // revision for example is like: 1.3.4
    // Remember the line befor the code and that after.

    public by cghersi @ MailUp API DEV modified Nov 19, 2014  112656  9  5  0

    How to Retrieve your personal information with MailUp .NET SDK

    This snippet takes advantage of the MailUp .NET SDK to setup the secure communication towards the server through OAuth2 two leg authentication. You can start digging into the MailUP API world by reading this content: http://help.mailup.com/display/mailupapi/REST+API An instance of MailUpClient class is able to manage one user at a time. A MailU
    public static void GetPersonalDataFields(string clientID, string clientSecret, string username, string password)
    {
        // 1) Setup the MailUp Client:
        MailUpClient client = new MailUpClient(clientID, clientSecret);
        try
        {
            client.RetrieveAccessToken(username, password);
        }
        catch (MailUpException ex)
        {
            Console.WriteLine("Unable to access the service due to " + ex.Message);
            return;
        }
    
        // 2) Prepare the input:
        //nothing to do here...
    
        // 3) Invoke the web method:
        CollectionOf<ConsoleDynamicFieldItem> result = null;
        try
        {
            result = client.GetPersonalDataFields();
        }
        catch (Exception ex)
        {
            Console.WriteLine("Cannot perform the operation due to " + ex.Message);
            return;
        }
    
    
        if (result != null)
            Console.WriteLine("Personal Data Fields Retrieved: " + result.Count);
        else
            Console.WriteLine("Cannot retrieve Personal Data Fields.");
    }
    

    public by cghersi @ MailUp API DEV modified Nov 19, 2014  68898  0  5  0

    How to Add a recipient to a group of recipients with MailUp .NET SDK

    This snippet takes advantage of the MailUp .NET SDK to setup the secure communication towards the server through OAuth2 two leg authentication. You can start digging into the MailUP API world by reading this content: http://help.mailup.com/display/mailupapi/REST+API An instance of MailUpClient class is able to manage one user at a time. A MailU
    public static void AddRecipientToGroup(string clientID, string clientSecret, string username, string password)
    {
        // 1) Setup the MailUp Client:
        MailUpClient client = new MailUpClient(clientID, clientSecret);
        try
        {
            client.RetrieveAccessToken(username, password);
        }
        catch (MailUpException ex)
        {
            Console.WriteLine("Unable to access the service due to " + ex.Message);
            return;
        }
    
        // 2) Prepare the input:
        int idGroup = 1;
        ConsoleRecipientItem recipient = new ConsoleRecipientItem()
        {
            Email = "testGroup@mailup.com",
            Name = "Group - New Recipient" + DateTime.Now.ToFileTimeUtc(),
            Fields = new List<ConsoleRecipientDynamicFieldItem>()
            {
                new ConsoleRecipientDynamicFieldItem() { Id = 1, Value = "NameGroup" + DateTime.Now.ToFileTimeUtc() },
                new ConsoleRecipientDynamicFieldItem() { Id = 2, Value = "LastNameGroup" + DateTime.Now.ToFileTimeUtc() }
                //here you can add all the fields you want to add...
            }
        };
    
        // 3) Invoke the web method:
        int result = 0;
        try
        {
            result = client.AddRecipientToGroup(idGroup, recipient);
        }
        catch (Exception ex)
        {
            Console.WriteLine("Cannot perform the operation due to " + ex.Message);
            return;
        }
    
        // 4) Print results:
        if (result > 0)
            Console.WriteLine("Recipient Added!");
        else
            Console.WriteLine("An error occurred while adding the recipient.");
    }
    

    public by cghersi @ MailUp API DEV modified Nov 19, 2014  59764  7  5  0

    How to Retrieve a group of recipients given its ID with MailUp .NET SDK

    This snippet takes advantage of the MailUp .NET SDK to setup the secure communication towards the server through OAuth2 two leg authentication. You can start digging into the MailUP API world by reading this content: http://help.mailup.com/display/mailupapi/REST+API An instance of MailUpClient class is able to manage one user at a time. A MailU
    public static void GetGroupByID(string clientID, string clientSecret, string username, string password)
    {
        // 1) Setup the MailUp Client:
        MailUpClient client = new MailUpClient(clientID, clientSecret);
        try
        {
            client.RetrieveAccessToken(username, password);
        }
        catch (MailUpException ex)
        {
            Console.WriteLine("Unable to access the service due to " + ex.Message);
            return;
        }
    
        // 2) Prepare the input:
        int idList = 1;
        int idGroup = 1;
    
        // 3) Invoke the web method:
        ConsoleGroupItem result = null;
        try
        {
            result = client.GetGroup(idList, idGroup);
        }
        catch (Exception ex)
        {
            Console.WriteLine("Cannot perform the operation due to " + ex.Message);
            return;
        }
    
        // 4) Print results:
        if (result != null)
            Console.WriteLine("Group retrieved with name:" + result.Name);
        else
            Console.WriteLine("An error occurred while retrieving the group.");
    }
    

    public by mporru @ Amazon_AWS_PHP_API modified Jul 23, 2013  133414  0  5  0

    Amazon AWS - PHP: Create a new Bucket

    This snippet demonstrates how to create a new Amazon S3 Bucket. In order to use this service you must enable Amazon Simple Storage Service (Amazon S3) in your account. Taken from: http://www.sitepoint.com/getting-started-with-the-aws-php-sdk/
    <?php
    require_once 'sdk.class.php';
    
    // Create the s3 Object from the SDK
    $s3 = new AmazonS3();
    // Run the Method: Create Bucket.
    // Arg 1: 'my-unique-bucket-name' is the name of your new bucket.
    // Arg 2: The geographical region where your data will be stored.
    // Arg 3: Tells Amazon to make your files readable by anyone like regular files hosted on a web server.
    $response = $s3->create_bucket('my-unique-bucket-name', AmazonS3::REGION_US_E1, AmazonS3::ACL_PUBLIC);
    // The response comes back as a Simple XML Object
    // In this case we just want to know if everything was okay.
    // If not, report the message from the XML response.
    if ((int) $response->isOK()) {
        echo 'Created Bucket';
    } else {
        echo (string) $response->body->Message;
    }
    
    ?>

    public by cghersi modified Oct 5, 2016  8278  1  5  0

    Preprovision a device via API with PLAT.ONE

    This is a way to use the PLAT.ONE API to create a device with a full structure: once the device is then active, it will be automatically integrated into the PLAT.ONE environment.
    // define the addressing information of the device:
    int netId = 1;			
    String deviceAddress = "100100";
    WSNNodeType nodeType = WSNNodeType.ENDPOINT;
    	
    // add sensor breakdown:
    List<LogNodeConfig> logNodeConfigs = new ArrayList<LogNodeConfig>();
    List<ObjectId> objsTemp = new ArrayList<ObjectId>();
    ObjectId objectIdTemp = frameParser.getObjID(0, 10);	// ObjectIdLow==0, ObjectIdHigh==10 = Temperature
    objsTemp.add(objectIdTemp);
    LogNodeConfig myNodeConf1 = frameParser.getLogNodeCfg(0, objsTemp, true);
    Tsap tsapTemp = frameParser.getTsap("AA:11:22:33:4E");
    myNodeConf1.setTsap(tsapTemp);
    logNodeConfigs.add(myNodeConf1);
    	
    // invoke the API
    ACSIresponseTicket<NodeIdentifier> ticket = null;
    try {
    	ticket = apiManager.ACSI_addNode(netId, nodeAddress, logNodeConfigs, nodeType, null);
    } catch (Exception e1) {
    	log.error("Could not create node ID= " + nodeAddress + ". "+ e1.getMessage());
    	return null;
    }
    
    log.trace("Ticket: " +  ticket.getRequestReturnCode());
    if (ticket.getRequestReturnCode() != ACSIreturnCodes.SUCCESS)
    	return null;
    
    nodeID = ticket.getResponse();
    if (nodeID!=null) {
    	log.info("Creating node: " + nodeID);
    } else {
    	log.error("CreateNode returned null NodeIdentifier");
    	return null;
    }          
    

    public by cghersi @ MailUp API DEV modified Nov 19, 2014  1073  29  5  0

    How to Retrieve and filter some lists of recipients with MailUp .NET SDK

    This snippet takes advantage of the MailUp .NET SDK to setup the secure communication towards the server through OAuth2 two leg authentication. You can start digging into the MailUP API world by reading this content: http://help.mailup.com/display/mailupapi/REST+API An instance of MailUpClient class is able to manage one user at a time. A MailU
    public static void GetLists(string clientID, string clientSecret, string username, string password)
    {
        // 1) Setup the MailUp Client:
        MailUpClient client = new MailUpClient(clientID, clientSecret);
        try
        {
            client.RetrieveAccessToken(username, password);
        }
        catch (MailUpException ex)
        {
            Console.WriteLine("Unable to access the service due to " + ex.Message);
            return;
        }
    
        // 2) Prepare the input:
        string filter = "Format.Trim().Equals('html')";
    
        // 3) Invoke the web method:
        CollectionOf<ConsoleListItem> result = null;
        try
        {
            result = client.GetLists(filter);
        }
        catch (Exception ex)
        {
            Console.WriteLine("Cannot perform the operation due to " + ex.Message);
            return;
        }
    
        // 4) Print results:
        if ((result != null) && (result.Count > 0))
            Console.WriteLine("Retrieved Lists:" + result.Count + "; first one with name:" + result[0].Name);
        else
            Console.WriteLine("An error occurred while retrieving the lists.");
    }
    

    public by FMXExpress modified Nov 12, 2014  7005  9  9  4

    Install A Shortcut On Android With Delphi XE5 Firemonkey

    http://www.fmxexpress.com/install-shortcuts-on-the-android-home-screen-with-delphi-xe5-firemonkey/
    //Android permission required:
    //<uses-permission android:name=”com.android.launcher.permission.INSTALL_SHORTCUT”/>
        
    Uses
    Androidapi.JNI.GraphicsContentViewText, FMX.Helpers.Android,
    Androidapi.JNI.JavaTypes, FMX.Platform.Android, AndroidApi.JniBridge, AndroidApi.Jni.App,
    AndroidAPI.jni.OS;
    
    {$IFDEF ANDROID}
    var
    ShortcutIntent: JIntent;
    addIntent: JIntent;
    wIconIdentifier : integer;
    wIconResource : JIntent_ShortcutIconResource;
    {$ENDIF}
    begin
    {$IFDEF ANDROID}
    
    ShortcutIntent := TJIntent.JavaClass.init(SharedActivityContext, SharedActivityContext.getClass);
    ShortcutIntent.setAction(TJIntent.JavaClass.ACTION_MAIN);
    
    addIntent := TJIntent.Create;
    addIntent.putExtra(TJIntent.JavaClass.EXTRA_SHORTCUT_INTENT, TJParcelable.Wrap((shortcutIntent as ILocalObject).GetObjectID));// here we need to cast the intent as it’s not done in delphi by default, not like java
    addIntent.putExtra(TJIntent.JavaClass.EXTRA_SHORTCUT_NAME, StringToJString(Application.Title));
    addIntent.setAction(StringToJString(‘com.android.launcher.action.INSTALL_SHORTCUT’));
    // get icon resource identifier
    wIconIdentifier := SharedActivity.getResources.getIdentifier(StringToJString(‘ic_launcher’), StringToJString(‘drawable’), StringToJString(‘com.embarcadero.HeaderFooterApplication’)); // if the app name change, you must change the package name
    wIconResource := TJIntent_ShortcutIconResource.JavaClass.fromContext(SharedActivityContext, wIconIdentifier);
    // set icon for shortcut
    addIntent.putExtra(TJIntent.JavaClass.EXTRA_SHORTCUT_ICON_RESOURCE, TJParcelable.Wrap((wIconResource as ILocalObject).GetObjectID));
    
    SharedActivityContext.sendBroadcast(addIntent);
    
    {$ENDIF}
     
    • Public Snippets
    • Channels Snippets