Exemplo n.º 1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $apiKey = env('LOB_API_KEY');
     $lob = new \Lob\Lob($apiKey);
     $file = View::make('templates/letter/sample')->render();
     $letter = $lob->letters()->create(['description' => 'Demo Letter', 'to[name]' => 'Harry Zhang', 'to[address_line1]' => '123 Test Street', 'to[address_city]' => 'Mountain View', 'to[address_zip]' => '94041', 'to[address_state]' => 'CA', 'to[address_country]' => 'US', 'from[name]' => 'Ami Wang', 'from[address_line1]' => '123 Test Avenue', 'from[address_city]' => 'Mountain View', 'from[address_zip]' => '94041', 'from[address_state]' => 'CA', 'from[address_country]' => 'US', 'file' => $file, 'color' => false]);
     dd($letter);
 }
<?php

/*
 * Script that sends a customized postcard to every row in a CSV File
 *
 * Usage: php postcards.php input.csv
 */
require '../../vendor/autoload.php';
$handle = fopen($argv[1], "r");
$html_front = file_get_contents('postcard_front.html');
$html_back = file_get_contents('postcard_back.html');
$lob = new \Lob\Lob('test_0dc8d51e0acffcb1880e0f19c79b2f5b0cc');
$from_address = $lob->addresses()->create(array('name' => 'The Big House', 'address_line1' => '1201 S Main St', 'address_line2' => '', 'address_city' => 'Ann Arbor', 'address_state' => 'MI', 'address_zip' => '48104', 'email' => '*****@*****.**', 'phone' => '734-647-2583'));
while ($row = fgetcsv($handle)) {
    $to_address = $lob->addresses()->create(array('name' => $row[5], 'address_line1' => $row[6], 'address_line2' => $row[7], 'address_city' => $row[8], 'address_state' => $row[9], 'address_zip' => $row[10], 'address_country' => $row[11]));
    $postcard = $lob->postcards()->create(array('to' => $to_address['id'], 'from' => $from_address['id'], 'front' => $html_front, 'back' => $html_back, 'setting' => 1002, 'data' => array('background_image' => $row[1], 'background_color' => $row[2], 'name' => $row[0], 'car' => $row[3], 'mileage' => $row[4])));
    printf($postcard['url'] . "\n");
    flush();
}
Exemplo n.º 3
0
<?php

require '../vendor/autoload.php';
$file = file_get_contents('html/card.html');
$lob = new \Lob\Lob('test_7c5d111af5ccfedb9f0eea91745c93896a1');
$to_address = $lob->addresses()->create(array('name' => 'Lob.com', 'address_line1' => '185 Berry Street', 'address_line2' => 'Suite 1510', 'address_city' => 'San Francisco', 'address_state' => 'CA', 'address_zip' => '94107', 'email' => '*****@*****.**', 'phone' => '555-555-5555'));
$from_address = $lob->addresses()->create(array('name' => 'The Big House', 'address_line1' => '1201 S Main St', 'address_line2' => '', 'address_city' => 'Ann Arbor', 'address_state' => 'MI', 'address_zip' => '48104', 'email' => '*****@*****.**', 'phone' => '734-647-2583'));
$postcard = $lob->postcards()->create(array('to' => $to_address['id'], 'from' => $from_address['id'], 'front' => $file, 'message' => 'Happy Birthday!', 'data[name]' => 'Harry'));
print_r($postcard);
Exemplo n.º 4
0
<?php

require '../vendor/autoload.php';
$lob = new \Lob\Lob('test_0dc8d51e0acffcb1880e0f19c79b2f5b0cc');
$bank_address = $lob->addresses()->create(array('name' => 'Bank Address', 'address_line1' => '123 Test Street', 'address_city' => 'San Francisco', 'address_state' => 'CA', 'address_zip' => '94158'));
$account_address = $lob->addresses()->create(array('name' => 'Lob.com', 'address_line1' => '185 Berry Street', 'address_line2' => 'Suite 1510', 'address_city' => 'San Francisco', 'address_state' => 'CA', 'address_zip' => '94107', 'email' => '*****@*****.**', 'phone' => '555-555-5555'));
$to_address = $lob->addresses()->create(array('name' => 'The Big House', 'address_line1' => '1201 S Main St', 'address_line2' => '', 'address_city' => 'Ann Arbor', 'address_state' => 'MI', 'address_zip' => '48104', 'email' => '*****@*****.**', 'phone' => '734-647-2583'));
$bank_account = $lob->bankAccounts()->create(array('routing_number' => '122100024', 'account_number' => '12345678', 'bank_address' => $bank_address['id'], 'account_address' => $account_address['id'], 'signatory' => 'John Doe'));
$bank_verify = $lob->bankAccounts()->verify($bank_account['id'], array(23, 34));
$check = $lob->checks()->create(array('description' => 'Season Tickets', 'to' => $to_address['id'], 'bank_account' => $bank_account['id'], 'amount' => 1000, 'memo' => 'Season Tickets', 'logo' => 'https://s3-us-west-2.amazonaws.com/lob-assets/lob_check_logo.png'));
print_r($check);
Exemplo n.º 5
0
<?php

require '../vendor/autoload.php';
$lob = new \Lob\Lob('test_7c5d111af5ccfedb9f0eea91745c93896a1');
$from_address = $lob->addresses()->create(array('name' => 'Jane Doe', 'address_line1' => '123 Hello Ave', 'address_city' => 'Providence', 'address_state' => 'RI', 'address_country' => 'US', 'address_zip' => '02912'));
$to_address = $lob->addresses()->create(array('name' => 'The Big House', 'address_line1' => '1201 S Main St', 'address_line2' => '', 'address_city' => 'Ann Arbor', 'address_state' => 'MI', 'address_zip' => '48104', 'email' => '*****@*****.**', 'phone' => '734-647-2583'));
$bank_account = $lob->bankAccounts()->create(array('routing_number' => '322271627', 'account_number' => '123456789', 'account_type' => 'company', 'signatory' => 'John Doe'));
$bank_verify = $lob->bankAccounts()->verify($bank_account['id'], array(23, 34));
$check = $lob->checks()->create(array('description' => 'Season Tickets', 'to' => $to_address['id'], 'from' => $from_address['id'], 'bank_account' => $bank_account['id'], 'amount' => 1000, 'memo' => 'Season Tickets', 'logo' => 'https://s3-us-west-2.amazonaws.com/lob-assets/lob_check_logo.png'));
print_r($check);
Exemplo n.º 6
0
<?php

require '../vendor/autoload.php';
$lob = new \Lob\Lob('test_0dc8d51e0acffcb1880e0f19c79b2f5b0cc');
$from_address = $lob->addresses()->create(array('name' => 'Lob.com', 'address_line1' => '185 Berry Street', 'address_line2' => 'Suite 1510', 'address_city' => 'San Francisco', 'address_state' => 'CA', 'address_zip' => '94107', 'email' => '*****@*****.**', 'phone' => '555-555-5555'));
$to_address = $lob->addresses()->create(array('name' => 'The Big House', 'address_line1' => '1201 S Main St', 'address_line2' => '', 'address_city' => 'Ann Arbor', 'address_state' => 'MI', 'address_zip' => '48104', 'email' => '*****@*****.**', 'phone' => '734-647-2583'));
$letter = $lob->letters()->create(array('to' => $to_address['id'], 'from' => $from_address['id'], 'file' => '<html><h1>Hello World</h1></html>', 'description' => 'Test Letters', 'color' => true));
print_r($letter);
Exemplo n.º 7
0
<?php

require '../vendor/autoload.php';
$lob = new \Lob\Lob('test_0dc8d51e0acffcb1880e0f19c79b2f5b0cc');
$routes = $lob->routes()->all(array('zip_codes' => '94158', 'zip_codes' => '94107'));
print_r($routes);
$area = $lob->areas()->create(array('description' => 'Sample SAM', 'routes' => '94158', 'routes' => '94107', 'front' => 'https://s3-us-west-2.amazonaws.com/lob-assets/areafront.pdf', 'back' => 'https://s3-us-west-2.amazonaws.com/lob-assets/areaback.pdf'));
print_r($area);
Exemplo n.º 8
0
<?php

require '../vendor/autoload.php';
$lob = new \Lob\Lob('test_7c5d111af5ccfedb9f0eea91745c93896a1');
$to_address = $lob->addresses()->create(array('name' => 'Lob.com', 'address_line1' => '185 Berry Street', 'address_line2' => 'Suite 1510', 'address_city' => 'San Francisco', 'address_state' => 'CA', 'address_zip' => '94107', 'email' => '*****@*****.**', 'phone' => '555-555-5555'));
$from_address = $lob->addresses()->create(array('name' => 'The Big House', 'address_line1' => '1201 S Main St', 'address_line2' => '', 'address_city' => 'Ann Arbor', 'address_state' => 'MI', 'address_zip' => '48104', 'email' => '*****@*****.**', 'phone' => '734-647-2583'));
$object = $lob->objects()->create(array('description' => 'Go Blue!', 'setting' => '500', 'file' => 'https://s3-us-west-2.amazonaws.com/lob-assets/lob-jelly-photo.jpg', 'quantity' => '1'));
$job = $lob->jobs()->create(array('to' => $to_address['id'], 'from' => $from_address['id'], 'object1' => $object['id']));
print_r($job);
Exemplo n.º 9
-2
 public function submitForm(Request $request)
 {
     //Get input
     $input = Input::all();
     //Date
     $input["Date"] = date("j/ n/ Y");
     //Bools for Parties
     if ($input["party"] == "Republican") {
         $input["Rep"] = "Yes";
     } else {
         $input["Dem"] = "Yes";
     }
     //concat name
     $input["Voter_Name"] = $input["first_name"] . " " . $input["last_name"];
     $contents = Storage::disk('local');
     $storagePath = Storage::disk('local')->getDriver()->getAdapter()->getPathPrefix();
     // $contents = Storage::get('reg.pdf');
     //Save as FDF
     $fdf = new FdfFile($input);
     $fdf->saveAs('data.fdf');
     $docId = md5(uniqid(rand(), true));
     //Save as Pdf
     $pdf = new Pdf($storagePath . 'template.pdf');
     $pdf->fillForm($fdf->getFileName())->saveAs($storagePath . "generated/" . $docId . '.pdf');
     //Setting up Lob
     $apiKey = env('LOB_KEY');
     $lob = new \Lob\Lob($apiKey);
     //Send the letter
     $letter = $lob->letters()->create(array('description' => 'Voter Registration', 'to[name]' => 'Town Clerk', 'to[address_line1]' => '230 Main St, Ste 108', 'to[address_city]' => 'Brattleboro', 'to[address_zip]' => '05301', 'to[address_state]' => 'VT', 'to[address_country]' => 'US', 'from[name]' => 'Benjamin Franklin', 'from[address_line1]' => '123 Fake Street', 'from[address_city]' => 'Philadelphia', 'from[address_zip]' => '94041', 'from[address_state]' => 'PA', 'from[address_country]' => 'US', 'file' => '@' . realpath($storagePath . "generated/" . $docId . '.pdf'), 'color' => false));
     $letter['file'] = $storagePath . "generated/" . $docId . '.pdf';
     return View::make('thanks', $letter)->with('data', $letter);
 }