Logical OR doesn't seem to work in Youtube (or PHP SDK) APIv3 list lookup
I am trying to find videos that match one of several keywords on a specific channel I'm connected to. I am using Officiel PHP SDK and this is what I have:
//client is a connected Google_Client
$youtube = new Google_Service_YouTube($client);
$pageToken = null;
$res = $youtube->search->listSearch(
'id, snippet', [
'maxResults' => 50,
'q' => "foo|bar",
'forMine' => true,
'type' => 'video',
'pageToken' => $pageToken
]
);
This will only return videos containing BOTH "foo" and "bar" instead of EFFER "foo" or "bar". I've also tried "foo | bar", "foo% 7Cbar", "urlencode (" foo | bar "," foo || bar ", but none of them give me what I want.
Did I miss something?
Thank.
source to share
From the documentation :
To search for a video that matches “boat” or “sail,” set the q parameter for boating.
Please note that the pipe symbol must be URL-escaped when posted in your API request. The value assigned to the URLs for the pipe symbol is% 7C.
Just tested your case and it works as expected, the column title
contains "foo" OR "bar".
"title": "KING OF THE BAR 2015 - Ultimate Calisthenics Battle!",
...
"title": "Foo Fighters",
...
"title": "Foo Fighters - Something From Nothing",
...
"title": "Browning BAR M1918",
...
"title": "Bar \"u Szwagra\" - Video Dowcip",
So, the problem must be in the PHP SDK.
source to share