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