In php, How would you convert a LongURL that contains & and?


#1

In php, How would you convert a LongURL that contains & and ?.

For example,
domainname.com/index.php?main_page=product_info&cPath=xx&products_id=xxxxxxxxx

Thanks in advance,


#2

What would you like to convert the URL into?


#3

Hello Kurrik,

Into a ShortURL. I’m getting an error when I submit it. The error is as follows:

Notice: Undefined index: http://www.domain.com/folder/index.php%3Fmain_page=product_info%26cPath=n%26products_id=nnnnnnnnn in /home/content/s/t/o/domain/html/Twitter/TwitterFeed.php on line 147
shortlink is:
Unable to generate shortlink from bit.ly

Line 147 contains:
$shortlink = $obj[“results”]["$url"][“shortUrl”];

Thanks again,


#4

Well, this has pretty much nothing to do with Twitter’s API, you’re having a problem indexing an associative array with a value which happens to be an URL.

It’s really hard to debug what might be the issue or where to encode/decode data without knowing where you’re getting $obj from, or seeing the code you’re using, or knowing which libraries you might be using. I’d suggest that you use PHP’s print_r function to print $obj and see what kind of data structure you’re working with.


#5