好的,如果不存在subto.me/args,我想将用户重定向回subto.me.com。
if(file_exists($BASEPATH."partials/".$request['args'][0].".php")) {
require($BASEPATH."partials/".$request['args'][0].".php");
} else {
header("Location: http://www.youtube.com/subscription_center?add_user=".$request['args'][0]);
}
如果youtube用户不存在,它会使用https://gdata.youtube.com/feeds/api/users/fdsafsdfasdfasd这样的链接表示。如果源代码等于“找不到用户”,我将如何配合使用
最佳答案
我有一个解决方案:
$yuser = "http://www.youtube.com/user/xxxx";
$yt_headers = @get_headers($yuser);
if($yt_headers[0] == 'HTTP/1.1 404 Not Found')
{ echo "Youtube user dosen't exist"; }
else { echo "Youtube user exists"; }
这可以用作使过程更漂亮的功能!
关于php - 检查YouTube用户是否存在PHP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16630960/