CURL Get Request with a parameter that contains a GET url

前端 未结 1 1899
名媛妹妹
名媛妹妹 2021-01-03 22:37

I\'m trying to make a cURL GET to scrape a Facebook Graph object:

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


        
相关标签:
1条回答
  • 2021-01-03 23:02

    You need to escape your parameters, 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
    
    0 讨论(0)
提交回复
热议问题