5 require_once __DIR__ . DIRECTORY_SEPARATOR . 'twitteroauth.php';
8 * We have to alter the TwitterOAuth class a little bit to work with any GNU Social
9 * installation abroad. Basically it's only make the API path variable and be happy.
11 * Thank you guys for the Twitter compatible API!
13 class StatusNetOAuth extends TwitterOAuth
15 function get_maxlength()
17 $config = $this->get($this->host . 'statusnet/config.json');
21 return $config->site->textlimit;
24 function accessTokenURL()
26 return $this->host . 'oauth/access_token';
29 function authenticateURL()
31 return $this->host . 'oauth/authenticate';
34 function authorizeURL()
36 return $this->host . 'oauth/authorize';
39 function requestTokenURL()
41 return $this->host . 'oauth/request_token';
44 function __construct($apipath, $consumer_key, $consumer_secret, $oauth_token = NULL, $oauth_token_secret = NULL)
46 parent::__construct($consumer_key, $consumer_secret, $oauth_token, $oauth_token_secret);
47 $this->host = $apipath;
51 * Make an HTTP request
53 * Copied here from the TwitterOAuth library and complemented by applying the proxy settings of Friendica
55 * @param string $method
58 * @param array $parameters
60 * @return array|object API results
62 function http($url, $method, $postfields = NULL)
64 $this->http_info = [];
67 $prx = DI::config()->get('system', 'proxy');
69 curl_setopt($ci, CURLOPT_HTTPPROXYTUNNEL, 1);
70 curl_setopt($ci, CURLOPT_PROXY, $prx);
71 $prxusr = DI::config()->get('system', 'proxyuser');
72 if (strlen($prxusr)) {
73 curl_setopt($ci, CURLOPT_PROXYUSERPWD, $prxusr);
76 curl_setopt($ci, CURLOPT_USERAGENT, $this->useragent);
77 curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, $this->connecttimeout);
78 curl_setopt($ci, CURLOPT_TIMEOUT, $this->timeout);
79 curl_setopt($ci, CURLOPT_RETURNTRANSFER, TRUE);
80 curl_setopt($ci, CURLOPT_HTTPHEADER, ['Expect:']);
81 curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, $this->ssl_verifypeer);
82 curl_setopt($ci, CURLOPT_HEADERFUNCTION, [$this, 'getHeader']);
83 curl_setopt($ci, CURLOPT_HEADER, FALSE);
87 curl_setopt($ci, CURLOPT_POST, TRUE);
88 if (!empty($postfields)) {
89 curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields);
93 curl_setopt($ci, CURLOPT_CUSTOMREQUEST, 'DELETE');
94 if (!empty($postfields)) {
95 $url = "{$url}?{$postfields}";
99 curl_setopt($ci, CURLOPT_URL, $url);
100 $response = curl_exec($ci);
101 $this->http_code = curl_getinfo($ci, CURLINFO_HTTP_CODE);
102 $this->http_info = array_merge($this->http_info, curl_getinfo($ci));