Skip to content

3. Examples

Sean edited this page Nov 10, 2016 · 2 revisions

Add Target

VWS::addTarget([
    'name' => 'my_new_target', 
    'width' => 320, 
    'path' => public_path('storage/IMG_2738.jpg')
    ]);   

=>

[
    "status" => 201,
    "body" => '{"result_code":"TargetCreated","transaction_id":"06c6ee2e5b374585bc977550496dd897","target_id":"c351ccbd3ed94cc1bd79a95fcb67c771"}',
]

Get Targets

VWS::getTargets();

=>

[
    "status" => 200,
    "body" => '{"result_code":"Success","transaction_id":"55a37243e36847028f8e4af146b7df41","results":["9150c85aba8a4105b0d1a79f00db9e03","7cdc64496d0440a3b99c87fa1693ac29","23ac317d8b52471782022be82084ff85","aa792b8d41c64f159c7b58ceddc096a4","d3b5d849fa284eed926ac4751f4f4542"]}',
]

Get Target

VWS::getTarget('9150c85aba8a4105b0d1a79f00db9e03');

=>

[
    "status" => 200,
    "body" => '{"result_code":"Success","transaction_id":"b4fb0409932a47ee9695c186cb4e69c7","target_record":{"target_id":"9150c85aba8a4105b0d1a79f00db9e03","active_flag":true,"name":"new_name","width":320,"tracking_rating":5,"reco_rating":""},"status":"success"}',
]

Update Target

VWS::updateTarget('c351ccbd3ed94cc1bd79a95fcb67c771', ['name' => 'fancy_name']);

=>

[                                                                                           
  "status" => 200,                                                                          
  "body" => '{"result_code":"Success","transaction_id":"668028a01b8b4fb88f1d4d821d36d451"}',
]     

Get Duplicates

VWS::getDuplicates('9150c85aba8a4105b0d1a79f00db9e03');

=>

[
    "status" => 200,
    "body" => '{"result_code":"Success","transaction_id":"5130420a63bc4827b36d7ddbd6333a8c","similar_targets":["23ac317d8b52471782022be82084ff85","7cdc64496d0440a3b99c87fa1693ac29"]}',
]

Delete Target

VWS::deleteTarget('c351ccbd3ed94cc1bd79a95fcb67c771');

=>

[
    "status" => 200,
    "body" => '{"result_code":"Success","transaction_id":"45b3ae592eaa439eb9c2a89def5311d7"}',
]

Get Database Summary

VWS::getDatabaseSummary();

=>

[
    "status" => 200,
    "body" => '{"name":"Development","result_code":"Success","transaction_id":"54d43d05bdb0499088d94a5aa0ce30c6","active_images":5,"inactive_images":0,"failed_images":0,"processing_images":0,"target_quota":1000,"request_quota":10000,"reco_threshold":1000,"request_usage":9,"total_recos":0,"current_month_recos":0,"previous_month_recos":0}',
]   

Get Target Summary

VWS::getTargetSummary('9150c85aba8a4105b0d1a79f00db9e03');

=>

[
    "status" => 200,
    "body" => '{"status":"success","result_code":"Success","transaction_id":"d1489350ffac4da8a6eb910fcf2c7979","database_name":"Development","target_name":"new_name","upload_date":"2016-10-27","active_flag":true,"tracking_rating":5,"total_recos":0,"current_month_recos":0,"previous_month_recos":0}',
]    

Use Target Class

$target = new Panoscape\Vuforia\Target;
$target->name = 'hello';

=>

Panoscape\Vuforia\Target { +name: "hello",
+width: null,
+image: null,
+active: null,
+metadata: null,
}

VWS::addTarget($target);
VWS::updateTarget('9150c85aba8a4105b0d1a79f00db9e03', $target);

HTTP Errors

[
    "status" => 500,
    "body" => "Unable to connect to tls://vws.vuforia.com:443. Error: php_network_getaddresses: getaddrinfo failed: This is usually a temporary error during hostname resolution and means that the local server did not receive a response from an authoritative server. ",
]

Errors from Vuforia Server

[
    "status" => 403,
    "body" => '{"result_code":"TargetNameExist","transaction_id":"a1b9bc59968341f7bef875d86573401f"}',
]    
VWS::addTarget(['name' => 'hahah', 'width' => 320, 'image' => 'x0']);

=>

[
    "status" => 422,
    "body" => '{"result_code":"BadImage","transaction_id":"d8029001a0804cfa9e3e20d15f3ecac4"}',
]      

Exceptions

VWS::addTarget([]);

=>

Exception with message 'Target name is required'

VWS::addTarget(['name' => 'a b c']);

=>

Exception with message 'Target name must have no spaces and may only contain: numbers (0-9), letters (a-z), underscores ( _ ) and dashes ( - )'

VWS::addTarget(['name' => 'hahah']);

=>

Exception with message 'Target width is required'

VWS::addTarget(['name' => 'hahah', 'width' => 320]);

=>

Exception with message 'Target image is required'

VWS::addTarget(['name' => 'hahah', 'width' => 320, 'path' => 'path']);

=>

Exception with message 'Failed to read image from path'