I need a help in search tweets queries parameters
mussaidris opened this issue · comments
Hi,
Please help me with the below errors :
- It is working without start_time and end_time eventhough it gives me some next_token errors , I will post it.
- It is working in Postman but using the program it is not , what the problem I don't know
- I am attaching you the messages and forms with my own code to analyse
4.==============
The below is my date conversion:
if($fromdate){
$fromdate= new \DateTime($fromdate);
$starttime=$fromdate->format(\DateTimeInterface::ATOM); // Updated ISO8601
array_push($params,['start_time'=>$starttime]);
}
if($todate){
$todate= new \DateTime($todate);
$todate=$todate->sub(new \DateInterval("PT30S"));
$endtime=$todate->format(\DateTimeInterface::ATOM); // Updated ISO8601
array_push($params,['end_time'=>$endtime]);
}
The below is one error when I use start time and end time parameters:
GuzzleHttp\Exception\ClientException
Client error: GET https://api.twitter.com/2/tweets/search/recent?query=%23nomore&tweet.fields=created_at%2Clang&max_results=100&expansions=author_id&user.fields=name%2Cusername&0%5Bstart_time%5D=2022-01-18T00:00:00%2B00:00&1%5Bend_time%5D=2022-01-23T23:59:30%2B00:00
resulted in a 400 Bad Request
response: {"errors":[{"parameters":{"1[end_time]":["2022-01-23T23:59:30+00:00"]},"message":"The query parameter [1[end_time]] is n (truncated...)
=================
The below is working but it is giving me error in the next_token pagination, but working only for 100 tweets.
GuzzleHttp\Exception\ClientException
Client error: GET https://api.twitter.com/2/tweets/search/recent?query=%23nomore&tweet.fields=created_at%2Clang&max_results=100&expansions=author_id&user.fields=name%2Cusername&0%5Bnext_token%5D=b26v89c19zqg8o3fpe4782uwnhbxdndndwsfb7cq81ev1
resulted in a 400 Bad Request
response: {"errors":[{"parameters":{"0[next_token]":["b26v89c19zqg8o3fpe4782uwnhbxdndndwsfb7cq81ev1"]},"message":"The query parame (truncated...)
Please help me on how to fix it.
Thanks and I am waiting for reply.
Mussa
Hi @mussaidris,
This issue isn't related to the library.
You can't push to a key/value array the way you are trying to.
instead of :
array_push($params,['start_time'=>$starttime]);
you should use:
$params['start_time'] = $starttime;
I'm going to close this now, feel free to reopen if I've misunderstood the issue.
Thanks a lot Daniel for your help!!
You are right it was from my side , not the library.
Thanks , working for me 100%