如果我尝试将此网址传递给Open Graph
$url = 'http://abc.com/index.php';
$facebook->api('/me/url_app:action','POST', array('something'=>$url));
一切都运转良好。
但是如果我尝试添加一些参数,比如
$url = 'http://abc.com/index.php?a=b&c=d';
$facebook->api('/me/url_app:action','POST', array('something'=>$url));
然后我会收到此错误
Fatal error: Uncaught Exception: Object at URL 'http://abc.com/index.php?a=b&c=d' of type 'url_app:action' is invalid because the given value '' for property 'og:url' could not be parsed as type 'url'. thrown in _PATH_/base_facebook.php on line 1050
为什么我无法在URL地址中添加一些参数?
编辑此外,这是编码链接的PHP函数:
function encodeURIComponent($str) {
$revert = array('%21'=>'!', '%2A'=>'*', '%27'=>"'", '%28'=>'(', '%29'=>')', '%3D'=>'=', '%3F'=>'?');
return strtr(rawurlencode($str), $revert);
}
答案 0 :(得分:0)
你必须对你的网址进行urlencode。
$ url = encodeURIComponent('http://abc.com/index.php?a=b&c=d');
$ facebook-> api('/ me / url_app:action','POST',array('something'=> $ url));
这可以解决您的问题......