Google API - URL Shortener with PHP

后端 未结 8 2030
爱一瞬间的悲伤
爱一瞬间的悲伤 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:52

    Don't have enough reputation points yet to comment, but I got this working fine by replacing the line:

    echo 'Shortened URL is: '.$json->id;
    

    with:

    $shortLink = get_object_vars($json);
    echo "Shortened URL is: ".$shortLink['id'];
    

    It could be just my php installation, but the original line kept throwing a 500 Internal Error for me.

提交回复
热议问题