CURL Get a request with a parameter containing a GET URL

I am trying to do a CURL GET to clear the facebook graph public object:

GET https://graph.facebook.com/?id= OBJECT_URL & scrape = true & method = post

In my case, OBJECT_URL contains GET parameters:

https://www.example.com/og.php?a=b&c=d

For this reason, I canโ€™t use it as a GET parameter in files_file_of_valuation () or CURLOPT_URL, since something like this would turn out:

https://graph.facebook.com/?id= https://www.example.com/og.php?a=b&c=d & scratch = true & method = post

Is there a way to pass it as a GET parameter in a way similar to CURLOPT_POSTFIELDS?

+6
source share
1 answer

You need to avoid your options, the http_build_query function will be useful:

$query = http_build_query([ 'id' => 'http://foo?a=1&b=2', 'scrape' => true, 'method' => 'post' ]); $url = "https://graph.facebook.com/?".$query; var_dump($url); 

This will output:

 https://graph.facebook.com/?id=http%3A%2F%2Ffoo%3Fa%3D1%26b%3D2&scrape=1&method=post 
+15
source

All Articles