Closed steven-cotterill closed 5 years ago
Also, there is a problem when passing single or double quotes through to $status. They appear as encoded characters on the actual tweet.
I've tried many functions to fix this; htmlspecialchars, htmlentities, addslashes etc. Any help here would be great.
@steven-cotterill Can you send me a sample code with status text containing a quote or double quote, along with the generated Tweet URL?
Also, to use Codebird concurrently on 2 accounts, you would have to set the consumer keys for every access. Will that work?
Hi, thanks for getting back. Code is unchanged from the original post.
You can see a number of tests on my test Twitter account (https://twitter.com/steventraffick). The text being sent is usually just an image (which is fine), and text of "Test" 'twitter' (to test the quotations) and a link to the article.
Code for posting to both accounts can be seen below, but won't post to the second account.
if ($page === 'both') { // Tweet to both accounts. Not working ATM.
\Codebird\Codebird::setConsumerKey ($public_consumer_key, $public_consumer_secret);
$cb = \Codebird\Codebird::getInstance();
$cb->setToken ($public_access_token, $public_access_token_secret);
// File upload
foreach ($media_files as $file) {
$reply = $cb->media_upload(array (
'media' => $file
));
$media_ids[] = $reply->media_id_string;
}
// Convert ID to string list
$media_ids = implode(',', $media_ids);
// Send Tweet and get response
$reply = $cb->statuses_update(array (
'status' => $status,
'media_ids' => $media_ids
));
$cb->logout();
\Codebird\Codebird::setConsumerKey ($trade_consumer_key, $trade_consumer_secret);
$cb->setToken ($trade_access_token, $trade_access_token_secret);
// File upload
foreach ($media_files as $file) {
$reply = $cb->media_upload(array (
'media' => $file
));
$media_ids[] = $reply->media_id_string;
}
// Convert ID to string list
$media_ids = implode(',', $media_ids);
// Send Tweet and get response
$reply = $cb->statuses_update(array (
'status' => $status,
'media_ids' => $media_ids
));
}
I've also tried following the steps in "…use multiple Codebird instances?" with no luck.
Thanks!
Hi there, any update with this? The main issue for me is the quotations being show as ’ etc. Thank you.
@stevie-c91 Can you give an example string for $status
that results in wrong entities being Tweeted?
Hi, I got this sorted. The user was copying strangely formatted text straight from a PDF. Thank you.
@stevie-c91 So the entities were in the PDF data already?
It's been a while now but IIRC the quotation marks were formatted strangely in the PDFs. When copied over, Twitter didn't have the font required to display them, so I don't think it's an issue with the library. Running a search and replace on the copied text, and changing them to proper quotation marks fixed the problem.
Hi, i've got the library working perfect posting to individual accounts. Is it possible to post to two seperate pages? There are different consumer keys and tokens. Any help here would be greatly appreciated.
` \Codebird\Codebird::setConsumerKey ($public_consumer_key, $public_consumer_secret); $cb = \Codebird\Codebird::getInstance(); $cb->setToken ($public_access_token, $public_access_token_secret);
`