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