Google API - URL Shortener with PHP

后端 未结 8 2026
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-02 12:24

My code is below. The URL shortening service works, but it doesn\'t when I insert my $POST. Does anyone know how to fix this my looking at the code?



        
8条回答
  •  时光说笑
    2021-02-02 12:44

    you are passing the php variable between the single quotes so it will not be parsed. pass it between double quotes like

    $longUrl = "http://www.mysite.com/XXXXX/XX/$_POST['qrname']";
    

    OR concatinate like this

    $longUrl = 'http://www.mysite.com/XXXXX/XX/'.$_POST['qrname'];
    

提交回复
热议问题