public function TwitterAPIExchange::setGetfield in Twitter Profile Widget 8
Same name and namespace in other branches
- 8.2 src/Resources/j7mbo/twitter_api_php/TwitterAPIExchange.php \Drupal\twitter_profile_widget\Resources\j7mbo\twitter_api_php\TwitterAPIExchange::setGetfield()
Set getfield string, example: '?screen_name=J7mbo'
Parameters
string $string Get key and value pairs as string:
Return value
\TwitterAPIExchange Instance of self for method chaining
Throws
\Exception
1 call to TwitterAPIExchange::setGetfield()
- TwitterAPIExchange::request in src/
Resources/ j7mbo/ twitter_api_php/ TwitterAPIExchange.php - Helper method to perform our request
File
- src/
Resources/ j7mbo/ twitter_api_php/ TwitterAPIExchange.php, line 151
Class
- TwitterAPIExchange
- Twitter-API-PHP : Simple PHP wrapper for the v1.1 API
Namespace
Drupal\twitter_profile_widget\Resources\j7mbo\twitter_api_phpCode
public function setGetfield($string) {
if (!is_null($this
->getPostfields())) {
throw new Exception('You can only choose get OR post fields.');
}
$getfields = preg_replace('/^\\?/', '', explode('&', $string));
$params = [];
foreach ($getfields as $field) {
if ($field !== '') {
list($key, $value) = explode('=', $field);
$params[$key] = $value;
}
}
$this->getfield = '?' . http_build_query($params);
return $this;
}