Saturday 8 June 2019

php - How to parse a variable?



I have the following test line in my PHP which works fine as a way of posting to Twitter from within my PHP code.



$oauth->post('statuses/update', array('status' => "hello world"));


However I want to post the contents of a variable as opposed to Hello World



If I change the code as follows, then all that gets posted is $message




$oauth->post('statuses/update', array('status' => '$message'));


I also tried without the ' but then nothing got posted, ie



$oauth->post('statuses/update', array('status' => $message));


How can I correctly parse the contents of $message?




$message is created as follows



$message = "http://www.smartphonesoft.com/index.php?option=com_mtree&task=viewlink&link_id=" .$link_id . " " ."Windows Phone Software" . " " .$link_name . " " . $metadesc;


I added an echo $message which showed me what I expected, namely:




http://www.smartphonesoft.com/index.php?option=com_mtree&task=viewlink&link_id=33183073

Windows Phone Software Pocket Player
Pocket Player is a rockin' way to
enjoy music and video on your Windows
Mobile device. Through multiple media
and playlist formats, Internet
connectivity, plugin extensions, and
an intuitive interface, Pocket Player
means less taps, more music!





Thanks,



Greg


Answer



From the Twitter API doc for status/update:




  • status The text of your status update, up to 140 characters. URL encode as necessary.




So I'd say you have to shorten the $message, because yours has 369 characters.


No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...