Closed whitesiroi closed 4 years ago
Your twurl version is using since_id
and your PHP version is using max_id
. If you switch the max_id
to since_id
the PHP version has next_results
.
> twurl "/1.1/search/tweets.json?q=#AFA2019&since_id=1182587607596687360&result_type=mixed&count=10" | jq '.search_metadata'
{
"completed_in": 0.031,
"max_id": 1273601471582331000,
"max_id_str": "1273601471582330880",
"next_results": "?max_id=1271731611097354239&q=%23AFA2019&count=10&include_entities=1&result_type=mixed",
"query": "%23AFA2019",
"refresh_url": "?since_id=1273601471582330880&q=%23AFA2019&result_type=mixed&include_entities=1",
"count": 10,
"since_id": 1182587607596687400,
"since_id_str": "1182587607596687360"
}
$connection = new TwitterOAuth(
CONSUMER_KEY,
CONSUMER_SECRET,
ACCESS_TOKEN,
ACCESS_TOKEN_SECRET
);
$tweetResult = $connection->get(
"search/tweets",
[
'q' => '#AFA2019',
'since_id' => '1182587607596687360',
'result_type' => 'mixed',
'count' => 10,
]
);
var_dump($tweetResult->search_metadata);
> php sample.php
object(stdClass)#42 (9) {
["completed_in"]=>
float(0.059)
["max_id"]=>
int(1273601471582330880)
["max_id_str"]=>
string(19) "1273601471582330880"
["next_results"]=>
string(86) "?max_id=1271731611097354239&q=%23AFA2019&count=10&include_entities=1&result_type=mixed"
["query"]=>
string(10) "%23AFA2019"
["refresh_url"]=>
string(79) "?since_id=1273601471582330880&q=%23AFA2019&result_type=mixed&include_entities=1"
["count"]=>
int(10)
["since_id"]=>
int(1182587607596687360)
["since_id_str"]=>
string(19) "1182587607596687360"
}
@abraham thank you very much for your help
Is there a way to use max_id
in the php version and still get the next_results
like with twurl
?
$ twurl /1.1/search/tweets.json?q=#高一ミスコン&max_id=1153128225284866050&result_type=mixed&count=2
"search_metadata": {
"completed_in": 0.074,
"max_id": 1274798554079322000,
"max_id_str": "1274798554079322112",
"next_results": "?max_id=1273177711868030977&q=%23%E9%AB%98%E4%B8%80%E3%83%9F%E3%82%B9%E3%82%B3%E3%83%B3&include_entities=1",
"query": "%23%E9%AB%98%E4%B8%80%E3%83%9F%E3%82%B9%E3%82%B3%E3%83%B3",
"refresh_url": "?since_id=1274798554079322112&q=%23%E9%AB%98%E4%B8%80%E3%83%9F%E3%82%B9%E3%82%B3%E3%83%B3&include_entities=1",
"count": 15,
"since_id": 0,
"since_id_str": "0"
}
Php code:
$tweetResult = $connection->get(
"search/tweets",
[
'q' => "#高一ミスコン",
'result_type' => 'mixed',
'max_id' => 1153128225284866050,
'count' => 2,
]
);
var_dump($tweetResult); die();
Result:
class stdClass#4 (2) {
public $statuses =>
array(0) {
}
public $search_metadata =>
class stdClass#9 (8) {
public $completed_in =>
double(0.003)
public $max_id =>
int(1153128225284866050)
public $max_id_str =>
string(19) "1153128225284866050"
public $query =>
string(57) "%23%E9%AB%98%E4%B8%80%E3%83%9F%E3%82%B9%E3%82%B3%E3%83%B3"
public $refresh_url =>
string(126) "?since_id=1153128225284866050&q=%23%E9%AB%98%E4%B8%80%E3%83%9F%E3%82%B9%E3%82%B3%E3%83%B3&result_type=mixed&include_entities=1"
public $count =>
int(2)
public $since_id =>
int(0)
public $since_id_str =>
string(1) "0"
}
}
I tested it with:
$ twurl /1.1/search/tweets.json?q=#AFA2019&since_id=1182587607596687360&result_type=mixed&count=10
But when I run it with php code:
I'm getting everything except
"next_results"
I'm using: