3 use Friendica\Core\Config;
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');
18 return $config->site->textlimit;
21 function accessTokenURL()
23 return $this->host . 'oauth/access_token';
26 function authenticateURL()
28 return $this->host . 'oauth/authenticate';
31 function authorizeURL()
33 return $this->host . 'oauth/authorize';
36 function requestTokenURL()
38 return $this->host . 'oauth/request_token';
41 function __construct($apipath, $consumer_key, $consumer_secret, $oauth_token = NULL, $oauth_token_secret = NULL)
43 parent::__construct($consumer_key, $consumer_secret, $oauth_token, $oauth_token_secret);
44 $this->host = $apipath;
48 * Make an HTTP request
50 * Copied here from the TwitterOAuth library and complemented by applying the proxy settings of Friendica
52 * @param string $method
55 * @param array $parameters
57 * @return array|object API results
59 function http($url, $method, $postfields = NULL)
61 $this->http_info = [];
64 $prx = DI::config()->get('system', 'proxy');
66 curl_setopt($ci, CURLOPT_HTTPPROXYTUNNEL, 1);
67 curl_setopt($ci, CURLOPT_PROXY, $prx);
68 $prxusr = DI::config()->get('system', 'proxyuser');
69 if (strlen($prxusr)) {
70 curl_setopt($ci, CURLOPT_PROXYUSERPWD, $prxusr);
73 curl_setopt($ci, CURLOPT_USERAGENT, $this->useragent);
74 curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, $this->connecttimeout);
75 curl_setopt($ci, CURLOPT_TIMEOUT, $this->timeout);
76 curl_setopt($ci, CURLOPT_RETURNTRANSFER, TRUE);
77 curl_setopt($ci, CURLOPT_HTTPHEADER, ['Expect:']);
78 curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, $this->ssl_verifypeer);
79 curl_setopt($ci, CURLOPT_HEADERFUNCTION, [$this, 'getHeader']);
80 curl_setopt($ci, CURLOPT_HEADER, FALSE);
84 curl_setopt($ci, CURLOPT_POST, TRUE);
85 if (!empty($postfields)) {
86 curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields);
90 curl_setopt($ci, CURLOPT_CUSTOMREQUEST, 'DELETE');
91 if (!empty($postfields)) {
92 $url = "{$url}?{$postfields}";
96 curl_setopt($ci, CURLOPT_URL, $url);
97 $response = curl_exec($ci);
98 $this->http_code = curl_getinfo($ci, CURLINFO_HTTP_CODE);
99 $this->http_info = array_merge($this->http_info, curl_getinfo($ci));