Helix Installation   Getting Started   Reference Documentation   Global Functions   Quick Start
ModulesClassesFunctions
 

Class Reference

class mturk extends obj

Helix obj mturk
Hide Inherited MembersAmazon Web Services
Description
No description.
 
Constants
No constants.
 
Properties
public_awsAccessKeyId[ mturk ]
public_baseURL[ mturk ]
public_credential[ mturk ]
protected_dirty[ obj ]
public_operation[ mturk ]
publicparameter[ mturk ]
publicproperty_objects_array[ obj ]
public_responseGroup[ mturk ]
public_secretKey[ mturk ]
public_service[ mturk ]
public_signature[ mturk ]
public_soapURL[ mturk ]
public_timestamp[ mturk ]
public_validate[ mturk ]
public_version[ mturk ]
 
Methods
publicApproveAssignment ( assignmentId , requesterFeedback )[ mturk ]
Parameters
requiredassignmentId
requiredrequesterFeedback
Code
083  public function ApproveAssignment($__assignmentId,$__requesterFeedback)
084  {
085      $this->parameter['Operation'] = "ApproveAssignment";
086      $this->parameter['AssignmentId'] = $__assignmentId;
087      $this->parameter['RequesterFeedback'] = $__requesterFeedback;
088      return $this->query();
089  }
publicAssignQualification ( )[ mturk ]
Parameters
No parameters for this method
Code
090  public function AssignQualification(){}
publicBlockWorker ( )[ mturk ]
Parameters
No parameters for this method
Code
091  public function BlockWorker(){}
publicChangeHITTypeOfHIT ( )[ mturk ]
Parameters
No parameters for this method
Code
092      public function ChangeHITTypeOfHIT(){}
publicCreateHIT ( hittypeid , question , lifetimeinseconds [604800] , maxassignments [1] , requesterannotation , title , description , reward , keywords , autoapprovaldelayinseconds , qualificationrequirement , assignmentdurationinseconds )[ mturk ]
Parameters
optionalhittypeid
optionalquestion
optionallifetimeinseconds [604800]
optionalmaxassignments [1]
optionalrequesterannotation
optionaltitle
optionaldescription
optionalreward
optionalkeywords
optionalautoapprovaldelayinseconds
optionalqualificationrequirement
optionalassignmentdurationinseconds
Code
093      public function CreateHIT($__hittypeid=null,$__question=null,$__lifetimeinseconds=604800,$__maxassignments=1,$__requesterannotation=null,$__title=null,$__description=null,$__reward=null,$__keywords=null,$__autoapprovaldelayinseconds=null,$__qualificationrequirement=null,$__assignmentdurationinseconds=null)
094      {
095          $this->parameter['Operation'] = "CreateHIT";
096     
097          if($__hittypeid)
098          {
099              $this->parameter['HITTypeId'] = $__hittypeid;
100          }
101          if($__question)
102          {
103              $this->parameter['Question'] = $__question;
104          }
105          if($__lifetimeinseconds)
106          {
107              $this->parameter['LifetimeInSeconds'] = $__lifetimeinseconds;
108          }
109          if($__maxassignments)
110          {
111              $this->parameter['MaxAssignments'] = $__maxassignments;
112          }
113          if($__title)
114          {
115              $this->parameter['Title'] = $__title;
116          }
117             if($__description)
118          {
119              $this->parameter['Description'] = $__description;
120          }
121          if($__keywords)
122          {
123              $this->parameter['Keywords'] = $__keywords;
124          }
125          if($__reward)
126          {
127              $this->parameter['Reward.1.Amount'] = $__reward->amount;
128          $this->parameter['Reward.1.CurrencyCode'] = $__reward->currencycode->abbreviation;
129          }
130          if($__autoapprovaldelayinseconds)
131          {
132              $this->parameter['AutoApprovalDelayInSeconds'] = $__autoapprovaldelayinseconds;
133          }
134          if($__qualificationrequirement)
135          {
136              $this->parameter['QualificationRequirement'] = $__qualificationrequirement;
137          }
138          if($__assignmentdurationinseconds)
139          {
140              $this->parameter['AssignmentDurationInSeconds'] = $__assignmentdurationinseconds;
141          }
142          if($__requesterannotation)
143          {
144              $this->parameter['RequesterAnnotation'] = $__requesterannotation;
145          }
146          return $this->query();
147      }
publicCreateQualificationType ( )[ mturk ]
Parameters
No parameters for this method
Code
148      public function CreateQualificationType(){}
publicDisableHIT ( hitid )[ mturk ]
Parameters
requiredhitid
Code
149      public function DisableHIT($__hitid){
150          $this->parameter['Operation'] = "DisableHIT";
151      $this->parameter['HITId'] = $__hitid;
152      return $this->query();
153      }
publicDisposeHIT ( hitid )[ mturk ]
Parameters
requiredhitid
Code
154      public function DisposeHIT($__hitid){
155          $this->parameter['Operation'] = "DisposeHIT";
156      $this->parameter['HITId'] = $__hitid;
157      return $this->query();
158      }
publicDisposeQualificationType ( )[ mturk ]
Parameters
No parameters for this method
Code
159      public function DisposeQualificationType(){}
publicExtendHIT ( hitid , maxassignmentsincrement , expirationincrementinseconds )[ mturk ]
Parameters
requiredhitid
requiredmaxassignmentsincrement
requiredexpirationincrementinseconds
Code
160      public function ExtendHIT($__hitid,$__maxassignmentsincrement,$__expirationincrementinseconds){
161          $this->parameter['Operation'] = "ExtendHIT";
162      $this->parameter['HITId'] = $__hitid;
163      $this->parameter['MaxAssignmentsIncrement'] = $__maxassignmentsincrement;
164      $this->parameter['ExpirationIncrementInSeconds'] = $__expirationincrementinseconds;
165      return $this->query();
166      }
publicForceExpireHIT ( )[ mturk ]
Parameters
No parameters for this method
Code
167      public function ForceExpireHIT(){}
publicGetAccountBalance ( )[ mturk ]
Parameters
No parameters for this method
Code
168      public function GetAccountBalance(){}
publicGetAssignmentsForHIT ( hitid )[ mturk ]
Parameters
requiredhitid
Code
169      public function GetAssignmentsForHIT($__hitid)
170      {
171          $this->parameter['Operation'] = "GetAssignmentsForHIT";
172      $this->parameter['HITId'] = $__hitid;
173      return $this->query();
174      }
publicGetBonusPayments ( )[ mturk ]
Parameters
No parameters for this method
Code
175      public function GetBonusPayments(){}
publicGetFileUploadURL ( )[ mturk ]
Parameters
No parameters for this method
Code
176  public function GetFileUploadURL(){}
publicGetHIT ( hitid )[ mturk ]
Parameters
requiredhitid
Code
177      public function GetHIT($__hitid)
178      {
179          $this->parameter['Operation'] = "GetHIT";
180      $this->parameter['HITId'] = $__hitid;
181      return $this->query();
182      }
publicGetHITsForQualificationType ( )[ mturk ]
Parameters
No parameters for this method
Code
183  public function GetHITsForQualificationType(){}
publicGetQualificationRequests ( )[ mturk ]
Parameters
No parameters for this method
Code
185      public function GetQualificationRequests(){}
publicGetQualificationScore ( )[ mturk ]
Parameters
No parameters for this method
Code
186  public function GetQualificationScore(){}
publicGetQualificationType ( )[ mturk ]
Parameters
No parameters for this method
Code
187  public function GetQualificationType(){}
publicGetQualificationsForQualificationType ( )[ mturk ]
Parameters
No parameters for this method
Code
184      public function GetQualificationsForQualificationType(){}
publicGetRequesterStatistic ( )[ mturk ]
Parameters
No parameters for this method
Code
214      public function GetRequesterStatistic(){}
publicGetReviewableHITs ( )[ mturk ]
Parameters
No parameters for this method
Code
188  public function GetReviewableHITs()
189  {
190      $this->parameter['Operation'] = "GetReviewableHITs";
191     
192      if ($this->HITTypeId)
193      {
194          $this->parameter['HITTypeId']     = $this->HITTypeId;
195      }
196      if ($this->Status)
197      {
198          $this->parameter['Status']        = $this->Status;
199      }
200      if (is_numeric($this->PageNumber) && $this->PageNumber > 0)
201      {
202          $this->parameter['PageNumber']    = $this->PageNumber;
203      }
204      if ($this->SortProperty)
205      {
206          $this->parameter['SortProperty']  = $this->SortProperty;
207      }
208      if ($this->SortDirection)
209      {
210          $this->parameter['SortDirection'] = $this->SortDirection;
211      }
212      return $this->query();
213  }
publicGrantBonus ( assignmentId , workerId , reason )[ mturk ]
Parameters
requiredassignmentId
requiredworkerId
requiredreason
Code
215      public function GrantBonus($__assignmentId,$__workerId,$__reason)
216      {
217          $this->parameter['Operation'] = "GrantBonus";
218      $this->parameter['AssignmentId'] = $__assignmentId;
219      $this->parameter['WorkerId'] = $__workerId;
220      $this->parameter['Reason'] = $__reason;
221      return $this->query();
222      }
publicGrantQualification ( )[ mturk ]
Parameters
No parameters for this method
Code
223      public function GrantQualification(){}
publicHelp ( about , helpType ["Operation"] )[ mturk ]
Parameters
requiredabout
optionalhelpType ["Operation"]
Code
230      public function Help($__about,$__helpType="Operation")
231      {
232          $this->parameter['Operation'] = "Help";
233      $this->parameter['About'] = $__about;
234      $this->parameter['HelpType'] = $__helpType; //Can either be HelpType or Operation
235      return $this->query();
236      }
publicNotifyWorkers ( workerID , subject , messageText )[ mturk ]
Parameters
requiredworkerID
requiredsubject
requiredmessageText
Code
237      public function NotifyWorkers($__workerID, $__subject,$__messageText)
238      {
239          $this->parameter['Operation'] = "NotifyWorkers";
240      $this->parameter['WorkerId'] = $__workerID;
241      $this->parameter['Subject'] = $__subject;
242      $this->parameter['MessageText'] = $__messageText;
243      return $this->query();
244      }
publicRegisterHITType ( )[ mturk ]
Parameters
No parameters for this method
Code
245      public function RegisterHITType(){}
publicRejectAssignment ( assignmentId , requesterFeedback )[ mturk ]
Parameters
requiredassignmentId
requiredrequesterFeedback
Code
246      public function RejectAssignment($__assignmentId,$__requesterFeedback)
247  {
248      $this->parameter['Operation'] = "RejectAssignment";
249      $this->parameter['AssignmentId'] = $__assignmentId;
250      $this->parameter['RequesterFeedback'] = $__requesterFeedback;
251      return $this->query();
252  }
publicRejectQualificationRequest ( )[ mturk ]
Parameters
No parameters for this method
Code
253      public function RejectQualificationRequest(){}
publicRevokeQualification ( )[ mturk ]
Parameters
No parameters for this method
Code
254      public function RevokeQualification(){}
publicSearchHITs ( pagesize [20] , pagenumber [1] , sortproperty ["Expiration"] , sortdirection ["Ascending"] )[ mturk ]
Parameters
optionalpagesize [20]
optionalpagenumber [1]
optionalsortproperty ["Expiration"]
optionalsortdirection ["Ascending"]
Code
255      public function SearchHITs($__pagesize=20,$__pagenumber=1,$__sortproperty='Expiration',$__sortdirection='Ascending'){
256          $this->parameter['Operation'] = "SearchHITs";
257     
258      $this->parameter['PageSize']      = $__pagesize;
259      $this->parameter['PageNumber']    = $__pagenumber;
260      $this->parameter['SortProperty']  = $__sortproperty;
261      $this->parameter['SortDirection'] = $__sortdirection;
262     
263      return $this->query();
264      }
publicSearchQualificationTypes ( )[ mturk ]
Parameters
No parameters for this method
Code
265      public function SearchQualificationTypes(){}
publicSendTestEventNotification ( )[ mturk ]
Parameters
No parameters for this method
Code
266      public function SendTestEventNotification(){}
publicSetHITAsReviewing ( )[ mturk ]
Parameters
No parameters for this method
Code
267      public function SetHITAsReviewing(){}
publicSetHITTypeNotification ( )[ mturk ]
Parameters
No parameters for this method
Code
268      public function SetHITTypeNotification(){}
publicUnblockWorker ( )[ mturk ]
Parameters
No parameters for this method
Code
269      public function UnblockWorker(){}
publicUpdateQualificationScore ( )[ mturk ]
Parameters
No parameters for this method
Code
270      public function UpdateQualificationScore(){}
publicUpdateQualificationType ( )[ mturk ]
Parameters
No parameters for this method
Code
271      public function UpdateQualificationType(){}
public__construct ( awsAccessKeyId , secretKey , sandbox [false] , version ["2006-08-23"] )[ mturk ]
Parameters
requiredawsAccessKeyId
requiredsecretKey
optionalsandbox [false]
optionalversion ["2006-08-23"]
Code
021  function __construct($__awsAccessKeyId, $__secretKey,$__sandbox=false,$__version = "2006-08-23")
022  {
023      $this->_service = "AWSMechanicalTurkRequester";
024      if($__sandbox || is_true(AWS_SANDBOX))
025      {
026          $this->_baseURL = "http://mechanicalturk.sandbox.amazonaws.com/onca/xml";
027          $this->_soapURL = "http://mechanicalturk.sandbox.amazonaws.com/onca/soap?Service={$this->_service}";
028      }
029      else {
030          $this->_baseURL = "http://mechanicalturk.amazonaws.com/onca/xml";
031          $this->_soapURL = "http://mechanicalturk.amazonaws.com/onca/soap?Service={$this->_service}";   
032      }
033      $this->_secretKey = $__secretKey;
034      $this->_awsAccessKeyId = $__awsAccessKeyId;
035      $this->_version = $__version;
036      $this->_responseGroup = "Minimal";
037     
038      $date = time() + (8*60*60);
039      $timestamp = date('Y-m-d\TH:i:s', $date);
040      $timestamp.=".000Z";
041      $this->_timestamp = $timestamp;
042      $this->parameter = array();
043  }
public__get ( p )[ obj ]
Parameters
requiredp
Code
007  public function __get($p)
008  {
009      $methods = get_class_methods($this);
010      $properties = get_object_vars($this);
011      if (in_array("get_$p",$methods))
012      {
013          return $this->{"get_$p"}();
014      }
015      else if (array_key_exists("_$p",$properties))
016      {
017          return $this->{"_$p"};
018      }
019      else if (in_array("get_" . substr($p,strpos($p,"_")+1), $methods))
020      {
021          return $this->{"get_" . substr($p,strpos($p,"_")+1)}(substr($p,0,strpos($p,"_")));
022      }
023      else
024      {
025          trigger_error("This object [" . get_class($this) . ":$this->id] has no private property '_$p' for the requested public property '$p'",E_USER_WARNING);
026          return null;
027      }
028  }
publicget_array ( )[ obj ]
Parameters
No parameters for this method
Code
096  public function get_array()
097  {
098      return get_object_vars($this);
099  }
publicget_classname ( )[ obj ]
Parameters
No parameters for this method
Code
086  public function get_classname()
087  {
088      return get_class($this);
089  }
publicget_dirty ( )[ obj ]
Parameters
No parameters for this method
Code
063  public function get_dirty()
064  {
065      if ($this->id === 0)
066      {
067          $this->_dirty = true;
068      }
069      else
070      {
071          foreach (get_object_vars($this) as $k=>$v)
072          {
073              if ($this->_dirty)
074              {
075                  break;
076              }
077              if (preg_match('/_dirty$/',$k))
078              {
079                  $this->_dirty = $this->_dirty || $v;
080              }
081          }
082      }
083      return $this->_dirty;
084  }
publicget_json ( )[ obj ]
Parameters
No parameters for this method
Code
101  public function get_json()
102  {
103      $class = new ReflectionClass($this->classname);
104      $methods = $class->getMethods();
105      usort($methods,"sort_reflection_objects");
106      $accessors = array();
107      foreach ($methods as $index=>$method)
108      {
109          $declarer = $method->getDeclaringClass()->name;
110          if (preg_match('/^(get|set|)_(.+)$/',$method->name,$matches))
111          {
112              $accessor = $matches[2];
113              $getset = $matches[1];
114              eval("\$accessors[\$accessor] = \$this->".$accessor.";");
115          }
116      }
117      //return json_encode($this->get_array());
118      return json_encode($accessors);
119  }
publicget_properties ( )[ obj ]
Parameters
No parameters for this method
Code
121  public function get_properties()
122  {
123      return array_keys($this->array);
124  }
publicget_signature ( )[ mturk ]
Parameters
No parameters for this method
Code
045  public function get_signature()
046  {
047      return base64_encode(hash_hmac("sha1",utf8_encode("{$this->service}{$this->parameter['Operation']}{$this->timestamp}"), $this->secretKey, true));
048  }
protectedget_string ( )[ obj ]
Parameters
No parameters for this method
Code
091  protected function get_string()
092  {
093      return method_exists($this,"__toString") ? $this->__toString() : null;
094  }
publicquery ( )[ mturk ]
Parameters
No parameters for this method
Code
050  public function query()
051  {
052      $data="";
053      //$this->signature = $this->HMAC();
054            $this->parameter['Service']        = $this->service;
055      $this->parameter['Version']        = $this->version;
056      $this->parameter['AWSAccessKeyId'] = $this->awsAccessKeyId;
057      $this->parameter['Timestamp']      = $this->timestamp;
058      $this->parameter['Signature']      = $this->signature;
059     
060      foreach ($this->parameter as $key => $val)
061      {
062          $callData[] = "{$key}=" . urlencode($val);       
063      }
064      $query   = $this->baseURL . "?" . implode($callData, "&");
065      $handler = @fopen($query, "r");
066      if   (!$handler) return false;
067      else
068      {
069         while (!feof($handler)) $data .= fgets($handler, 2048);
070         fclose($handler);
071         if   (strlen($data) < 4)
072         {
073            $return = FALSE;
074         }
075         else
076         {
077           $return = $data;
078         }
079      }
080      return $return;
081  }
public__set ( p , v )[ obj ]
Parameters
requiredp
requiredv
Code
030  public function __set($p,$v)
031  {
032      $methods = get_class_methods($this);
033      $properties = get_object_vars($this);
034      if (in_array("set_$p",$methods))
035      {
036          $this->{"set_$p"}($v);
037      }
038      else if (array_key_exists("_$p",$properties))
039      {
040          if (!preg_match('/_dirty$/',$p) && property_exists($this,"_{$p}_dirty"))
041          {
042              if (is_object($this->{"_$p"}))
043              {
044                  $this->{"_$p"}->dirty = true;
045              }
046              else
047              {
048                  $this->{"_{$p}_dirty"} = $this->{$p}==$v ? false : true;
049              }
050          }
051          $this->{"_$p"} = $v;
052      }
053      else if (in_array("set_" . substr($p,strpos($p,"_")+1), $methods))
054      {
055          $this->{"set_" . substr($p,strpos($p,"_")+1)}($v,substr($p,0,strpos($p,"_")));
056      }
057      else
058      {
059          trigger_error("This object [" . get_class($this) . ":$this->id] has no private property '_$p' for the requested public property '$p'",E_USER_WARNING);
060      }
061  }
 
Accessors
publicarray[ obj ]
Code
096  public function get_array()
097  {
098      return get_object_vars($this);
099  }
publicclassname[ obj ]
Code
086  public function get_classname()
087  {
088      return get_class($this);
089  }
publicdirty[ obj ]
Code
063  public function get_dirty()
064  {
065      if ($this->id === 0)
066      {
067          $this->_dirty = true;
068      }
069      else
070      {
071          foreach (get_object_vars($this) as $k=>$v)
072          {
073              if ($this->_dirty)
074              {
075                  break;
076              }
077              if (preg_match('/_dirty$/',$k))
078              {
079                  $this->_dirty = $this->_dirty || $v;
080              }
081          }
082      }
083      return $this->_dirty;
084  }
publicjson[ obj ]
Code
101  public function get_json()
102  {
103      $class = new ReflectionClass($this->classname);
104      $methods = $class->getMethods();
105      usort($methods,"sort_reflection_objects");
106      $accessors = array();
107      foreach ($methods as $index=>$method)
108      {
109          $declarer = $method->getDeclaringClass()->name;
110          if (preg_match('/^(get|set|)_(.+)$/',$method->name,$matches))
111          {
112              $accessor = $matches[2];
113              $getset = $matches[1];
114              eval("\$accessors[\$accessor] = \$this->".$accessor.";");
115          }
116      }
117      //return json_encode($this->get_array());
118      return json_encode($accessors);
119  }
publicproperties[ obj ]
Code
121  public function get_properties()
122  {
123      return array_keys($this->array);
124  }
publicsignature[ mturk ]
Code
045  public function get_signature()
046  {
047      return base64_encode(hash_hmac("sha1",utf8_encode("{$this->service}{$this->parameter['Operation']}{$this->timestamp}"), $this->secretKey, true));
048  }
publicstring[ obj ]
Code
091  protected function get_string()
092  {
093      return method_exists($this,"__toString") ? $this->__toString() : null;
094  }
Get Helix PHP Framework at SourceForge.net. Fast, secure and Free Open Source software downloads