Post Arabic lang from PHP


i am using the abraham’ tweeter oauth library to post status updates to tweeter
when i post some text in English it works good but when i try to post Arabic content it gives error

can any one help??
any sample code will be appreciated

my current code

include 'lib/EpiCurl.php';
include 'lib/EpiOAuth.php';
include 'lib/EpiTwitter.php';
include 'lib/secret.php';
header("Content-Type: text/html; charset=UTF-8");

$twitterObj = new EpiTwitter($consumer_key, $consumer_secret);

		$twitterObj->setToken($_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);
		$update_status = $twitterObj->post_statusesUpdate(array('status' => "الخيال اهلا وسهلا بكم في عالم"));
		$temp = $update_status->response;

		echo "<div align='center'>Tweet Posted.</div>";


I’d recommend using tmhOAuth or twitteroauth in PHP rather than EpiTwitter.

This is likely failing due to an encoding error. Make sure that:

  • the Arabic is being posted as UTF-8 content.
  • When POSTing, it’s best that “الخيال اهلا وسهلا بكم في عالم” gets sent as “%D8%A7%D9%84%D8%AE%D9%8A%D8%A7%D9%84%20%D8%A7%D9%87%D9%84%D8%A7%20%D9%88%D8%B3%D9%87%D9%84%D8%A7%20%D8%A8%D9%83%D9%85%20%D9%81%D9%8A%20%D8%B9%D8%A7%D9%84%D9%85”
  • The OAuth signature base string needs to then have that escaped again: “%25D8%25A7%25D9%2584%25D8%25AE%25D9%258A%25D8%25A7%25D9%2584%2520%25D8%25A7%25D9%2587%25D9%2584%25D8%25A7%2520%25D9%2588%25D8%25B3%25D9%2587%25D9%2584%25D8%25A7%2520%25D8%25A8%25D9%2583%25D9%2585%2520%25D9%2581%25D9%258A%2520%25D8%25B9%25D8%25A7%25D9%2584%25D9%2585”

The library you’re using may be taking care of none, all, or only part of this for you. Experimentation should help you figure out which it is.


Thanks using tmhOAuth solved the issue