예제 #1
0
 public function __construct($authKeys = array())
 {
     $opts = array("headers" => array("User-Agent" => "twitter-wrapi"), "query" => array("stringify_ids" => "true"), 'auth' => 'oauth');
     $handler = HandlerStack::create();
     $handler->push(new Oauth1($authKeys));
     function build(&$obj, $prefix, $apiList)
     {
         $path = $prefix;
         if ($prefix !== '') {
             $path .= '/';
         }
         foreach ($apiList as $name) {
             $json = file_get_contents(__DIR__ . '/api/' . $path . $name . '.json');
             $endpoint = json_decode($json, true);
             $pre = $prefix === '' ? $name : $prefix . '.' . $name;
             foreach ($endpoint as $sub => $ep) {
                 $obj[$pre . '.' . $sub] = $ep;
             }
         }
     }
     $all = [];
     build($all, '', ['statuses', 'media', 'direct_messages', 'search', 'friendships', 'friends', 'followers', 'account', 'blocks', 'users', 'favorites', 'lists', 'saved_searches', 'geo', 'trends', 'application', 'help']);
     build($all, 'users', ['suggestions']);
     build($all, 'lists', ['members', 'subscribers']);
     parent::__construct('https://api.twitter.com/1.1/', $all, $opts, ['handler' => $handler]);
 }
예제 #2
0
파일: slack.php 프로젝트: palanik/slack-php
 public function __construct($token)
 {
     $opts = array("headers" => array("User-Agent" => "slack-wrapi"), "query" => array("token" => $token));
     $json = file_get_contents(__DIR__ . '/api/slack.json');
     $endpoints = json_decode($json, true);
     parent::__construct('https://slack.com/api/', $endpoints, $opts);
 }