{"id":6322,"date":"2014-04-15T19:46:19","date_gmt":"2014-04-15T19:46:19","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/04\/15\/facebook-open-graph-how-to-pass-parameters-in-url-collection-of-common-programming-errors\/"},"modified":"2014-04-15T19:46:19","modified_gmt":"2014-04-15T19:46:19","slug":"facebook-open-graph-how-to-pass-parameters-in-url-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/04\/15\/facebook-open-graph-how-to-pass-parameters-in-url-collection-of-common-programming-errors\/","title":{"rendered":"Facebook Open Graph &#8211; how to pass parameters in URL?-Collection of common programming errors"},"content":{"rendered":"<p>If I will try to pass this URL into Open Graph<\/p>\n<pre><code>$url = 'http:\/\/abc.com\/index.php';\n$facebook-&gt;api('\/me\/url_app:action','POST', array('something'=&gt;$url));\n<\/code><\/pre>\n<p>everything is working well. But if I try to add some parameters, like<\/p>\n<pre><code>$url = 'http:\/\/abc.com\/index.php?a=b&amp;c=d';\n$facebook-&gt;api('\/me\/url_app:action','POST', array('something'=&gt;$url));\n<\/code><\/pre>\n<p>then I will get this error<\/p>\n<pre><code>Fatal error: Uncaught Exception: Object at URL 'http:\/\/abc.com\/index.php?a=b&amp;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\n<\/code><\/pre>\n<p>Why I cannot add some parameters to the URL address?<\/p>\n<p><strong>EDIT<\/strong> Also, here is the PHP function for encoding link:<\/p>\n<pre><code>function encodeURIComponent($str) {\n    $revert = array('%21'=&gt;'!', '%2A'=&gt;'*', '%27'=&gt;\"'\", '%28'=&gt;'(', '%29'=&gt;')', '%3D'=&gt;'=', '%3F'=&gt;'?');\n    return strtr(rawurlencode($str), $revert);\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>If I will try to pass this URL into Open Graph $url = &#8216;http:\/\/abc.com\/index.php&#8217;; $facebook-&gt;api(&#8216;\/me\/url_app:action&#8217;,&#8217;POST&#8217;, array(&#8216;something&#8217;=&gt;$url)); everything is working well. But if I try to add some parameters, like $url = &#8216;http:\/\/abc.com\/index.php?a=b&amp;c=d&#8217;; $facebook-&gt;api(&#8216;\/me\/url_app:action&#8217;,&#8217;POST&#8217;, array(&#8216;something&#8217;=&gt;$url)); then I will get this error Fatal error: Uncaught Exception: Object at URL &#8216;http:\/\/abc.com\/index.php?a=b&amp;c=d&#8217; of type &#8216;url_app:action&#8217; is invalid because the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-6322","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6322","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=6322"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6322\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=6322"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=6322"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=6322"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}