コード例 #1
0
ファイル: Draft.php プロジェクト: barricas/Brush
 /**
  * Submit this draft paste to the Pastebin API.
  * @param \Brush\Accounts\Developer $developer The developer account to use to send the request.
  * @return \Brush\Pastes\Paste The created paste.
  */
 public function paste(Developer $developer)
 {
     // throw on any errors
     $this->validate();
     // create the request
     $pastebin = new ApiRequest($developer, self::ENDPOINT);
     $pastebin->setOption('paste');
     $this->addTo($pastebin->getRequest(), $developer);
     // send and create a paste from this draft
     return Paste::fromPasted($pastebin->send(), $this);
 }
コード例 #2
0
ファイル: Paste.php プロジェクト: C00LTypucT/Brush
 /**
  * Create a paste instance from a key and draft.
  * @param string $url The URL of the paste.
  * @param \Brush\Pastes\Draft $draft The draft to import.
  * @return \Brush\Pastes\Paste The created paste.
  */
 public static function fromPasted($url, Draft $draft)
 {
     $paste = new Paste();
     $paste->import($draft);
     $paste->setUrl($url);
     $paste->setDate(time());
     $paste->setHits(0);
     $offset = Expiry::getOffset($draft->getExpiry());
     $paste->setExpires($offset == 0 ? 0 : $paste->getDate() + $offset);
     return $paste;
 }
コード例 #3
0
ファイル: Trending.php プロジェクト: barricas/Brush
 /**
  * Get the 18 currently trending pastes.
  * @param \Brush\Accounts\Developer $developer The developer account to use for the request.
  * @return \Brush\Pastes\Paste[] Trending pastes.
  */
 public static function getPastes(Developer $developer)
 {
     $pastebin = new ApiRequest($developer, self::ENDPOINT);
     $pastebin->setOption('trends');
     return Paste::parsePastes($pastebin->send());
 }
コード例 #4
0
ファイル: Account.php プロジェクト: barricas/Brush
 /**
  * Retrieve pastes created by this account in descending order of date created.
  * @param \Brush\Accounts\Developer $developer The developer account to use for the request.
  * @param int $limit The maximum number of pastes to retrieve. 1 <= $number <= 1000. Defaults to 50.
  * @throws \Brush\Exceptions\ArgumentException If the number of pastes is outside the allowed range.
  * @return \Brush\Pastes\Paste[] This account's pastes, up to the limit.
  */
 public function getPastes(Developer $developer, $limit = 50)
 {
     // check 1 <= $number <= 1000
     if ($limit < 1 || $limit > 1000) {
         throw new ArgumentException('The number of pastes must be in the range 1 to 1000 inclusive.');
     }
     $pastebin = new ApiRequest($developer, self::PASTES_ENDPOINT);
     $pastebin->setOption('list');
     $request = $pastebin->getRequest();
     $this->sign($request, $developer);
     $request->getVariables()->set('api_results_limit', $limit);
     return Paste::parsePastes($pastebin->send(), $this);
 }