douyin2883 2014-05-04 08:56 采纳率: 0%
浏览 57
已采纳

在我创建的php字符串中有一个随机行

I am working on a small app that uses the shareaholic API in PHP. I created a small function that will cunstruct the correct url. When the string is returned it returns it with a line break after the v. Output below:

http://www.shareaholic.com/api/share/?v=1&apitype=1&apikey=#################################&service=5&link=http://website.com/contest-page/&title=Website&notes=I+voted+for+Example5%27s+photo+to+win

So the browser only gets the url up to the /?

here is the php

function createShareToLink($serv, $name){
    $sharebase = 'http://www.shareaholic.com/api/share/?v=1';
    $apitype = "&apitype=1";
    $apikey = "&apikey=redacted";
    $twitter = false;

    $title = trim("redacted");
    $title = urlencode($title);
    $url = "http://redacted.com/contest-page/";
    $msg = urlencode("I voted for $name's photo to win");


    switch($serv){
        case 1: //facebook
            $service = "&service=5";
            break;
        case 2: //twitter
            $twitter = true;
            $service = "&service=7";
            break;
        case 3: //Google        
            $service = "&service=304";
            break;
        default:
            $service = "&service=5";
            break;
    }

    if(!$twitter){
        $shareurl = $sharebase . $apitype . $apikey . $service . '&link=' . $url . '&title=' . $title . '&notes=' . $msg;
    } else {
        $shareurl = $sharebase . $apitype . $apikey . $service . '&link=' . $url . '&title=' . $title . '&template=redacted.com%20100lbs%20BBQ%20Giveaway%20${short_link}%20via%20@redacted%20%23Contest%20%23Giveaway';
    }

    return $shareurl;
}

I have never run into this, any ideas? Output displayed in WordPress Into a HTML form, I can see the entire link, but it breaks right after the ? which is that is passed to the browser on click. Also shareaholic api returns that all info is null.

  • 写回答

1条回答 默认 最新

  • doumizhi0809 2014-05-04 21:13
    关注

    Ok this is odd to me, but I got it working and that is all that matters I was using this:

    echo '<form action="' . $fblink . '" target="_blank" method="get"><input type="submit" id="fblink"></form>';
    

    Which would send only the fist part, like I mentioned above.

    I changed it to a div wrapped link and it works fine now. I don't really know why the other way wouldn't work but it works now so whatever.

    Thanks everyone.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败
  • ¥15 树莓派5怎么用camera module 3啊
  • ¥20 java在应用程序里获取不到扬声器设备
  • ¥15 echarts动画效果的问题,请帮我添加一个动画。不要机器人回答。
  • ¥15 Attention is all you need 的代码运行