post() public method

Performs a POST request. Used for pretty much everything.
public post ( string $endpoint, array $data, array $params, boolean $multipart = FALSE ) : mixed
$endpoint string The address of the resource being requested (e.g. '/update_snaps' or '/friend').
$data array An dictionary of values to send to the API. A request token is added automatically.
$params array An array containing the parameters used to generate the request token.
$multipart boolean If TRUE, sends the request as multipart/form-data. Defaults to FALSE.
return mixed The data returned from the API (decoded if JSON). Returns FALSE if the request failed.
示例#1
0
 /**
  * Updates the current user's email address.
  *
  * @param string $email
  *   The new email address.
  *
  * @return bool
  *   TRUE if successful, FALSE otherwise.
  */
 public function updateEmail($email)
 {
     // Make sure we're logged in and have a valid access token.
     if (!$this->auth_token || !$this->username) {
         return FALSE;
     }
     $timestamp = parent::timestamp();
     $result = parent::post('/settings', array('action' => 'updateEmail', 'email' => $email, 'timestamp' => $timestamp, 'username' => $this->username), array($this->auth_token, $timestamp));
     return isset($result->param) && $result->param == $email;
 }
示例#2
0
 /**
  * Download the user's Snaptag, a jazzed up QR code with a ghost in the middle.
  *
  * @return data
  *   Snaptag data
  */
 public function getSnaptag()
 {
     $updates = $this->getUpdates();
     if (empty($updates)) {
         return FALSE;
     }
     $snaps = array();
     $qr = $updates['data']->updates_response->qr_path;
     $timestamp = parent::timestamp();
     $result = parent::post('/bq/snaptag_download', array('image' => $qr, 'timestamp' => $timestamp, 'username' => $this->username), array($this->auth_token, $timestamp), $multipart = false, $debug = $this->debug);
     return $result;
 }
示例#3
0
文件: snapchat.php 项目: k1bb1/SC-API
 /**
  * Set/update your location for geofilters, weather info, and local stories.
  *
  * @param int $lat
  *   Latitude.
  *
  * @param int $lon
  *   Longitude.
  *
  * @param int $acc
  *   Accuracy in meters.
  *
  * @return json array
  *   Returns a JSON array with geofilters, local our stories, weather, and lens filters.
  */
 public function setLocation($lat, $lon, $acc)
 {
     $timestamp = parent::timestamp();
     $result = parent::post('/loq/loc_data', array('timestamp' => $timestamp, 'lat' => $lat, 'long' => $lon, 'loc_accuracy_in_meters' => $acc, 'checksums_dict' => '{}', 'username' => $this->username), array($this->auth_token, $timestamp), $multipart = false, $debug = $this->debug);
     return $result;
 }