如何在curl php中发布和获取阿拉伯语单词

时间:2014-11-28 07:34:39

标签: php curl

嗨将以下输出作为

输出到我的curl页面

数组([0] =>数组([news_id] => 126388 [news_title] =>رئيسالدولةبخيروعافيةوصحتهطيبة[news_date] => 2014-11-27 03:17:03 [标签] ] =>إماراتنا,الأولى[news_detail] =>أكدهالأرضيان,طيباللهثراه,مؤسسوبانيهذهالدولةوإخوانهحكامالإماراتالأوائليرحمهماللهجميعاوأعربسهيلالمرروأفرادأسرتهعنشكرهموامتنانهملسمووليعهدأبوظبيعلىتلبيتهالدعوةوزيارتهم, مرحبينوأفرادالأسرةبهذهالزيارةالكريمةالتيتعبرعنعمقالروابطوالتواصلبينقيادةدولةالإماراتالعربيةالمتحدةوأبناءالوطن。رافقسموهفيالزيارةالفريقسموالشيخسيفبنزايدآلنهياننائبرئيسمجلسالوزراءوزيرا لداخلية,وعبداللهمهيرالكتبي,ومحمدمباركالمزروعيوكيلديوانوليالعهد。[term_id] => 7 [news_category] ​​=> home-news [news_name] =>إماراتنا[news_key] => source [news_source] => وامأبوظبي[news_image] => http://test.com//wp-content/uploads/))

当我通过curl发布此内容并在发布的php页面中获取上述数组时,我得到了??????

代码如下

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php
$host="localhost";
$username="root";
$password="";
$db_name="demo"; 
mysql_connect("$host", "$username", "$password")or die("cannot connect to server");
mysql_select_db("$db_name")or die("cannot select db");
$sSQL= 'SET CHARACTER SET utf8';
   mysql_query($sSQL);
   $date="2014-11-27";

$query="SELECT wp_posts.ID as Id,wp_posts.post_title as Title,wp_posts.post_date as DATE,wp_postmeta.meta_key,wp_postmeta.meta_value,
GROUP_CONCAT(wp_terms.name) AS TAGS, wp_posts.post_content as CONTENT,wp_terms.term_id,wp_terms.slug,wp_terms.name,wp_posts.post_parent as parent_id FROM wp_terms
INNER JOIN wp_term_taxonomy ON wp_terms.term_id  = wp_term_taxonomy.term_id
INNER JOIN wp_term_relationships ON wp_term_taxonomy.term_taxonomy_id = wp_term_relationships.term_taxonomy_id
INNER JOIN wp_posts ON wp_posts.ID = wp_term_relationships.object_id
INNER JOIN wp_postmeta ON(wp_posts.ID = wp_postmeta.post_id)
WHERE post_type LIKE 'post' AND post_status LIKE 'publish' and meta_key='source' and post_date like '%$date%'
GROUP BY wp_posts.ID order by post_date DESC limit 10";

 $query_run=  mysql_query($query);
        while ($row = mysql_fetch_assoc($query_run)) {
            $meta_value_id=  "select meta_value from wp_postmeta where meta_key='_thumbnail_id' and post_id='".$row['Id']."'";   
            $query_run_meta=  mysql_query($meta_value_id);
            $row1=  mysql_fetch_assoc($query_run_meta);

            $meta_image=  "select meta_value from wp_postmeta where meta_key='_wp_attached_file' and post_id='".$row1['meta_value']."'";   
            $query_meta=  mysql_query($meta_image);
            $row2=  mysql_fetch_assoc($query_meta);



            $detail['news_id']=($row['Id']);
            $detail['news_title']=(strip_tags($row['Title']));
            $detail['news_date']=(strip_tags($row['DATE']));
            $detail['TAGS']=(strip_tags($row['TAGS']));
            $detail['news_detail']=(strip_tags($row['CONTENT']));
            $detail['term_id']=($row['term_id']);
            $detail['news_category']=(strip_tags($row['slug']));
            $detail['news_name']=(strip_tags($row['name']));
            $detail['news_key']=(strip_tags($row['meta_key']));
            $detail['news_source']=(strip_tags($row['meta_value']));
            $detail['news_image']=("http://test.com//wp-content/uploads/".$row2['meta_value']);   


             $details[]=$detail; 
         }

         //for test the data;
         print_r($details);

      $str=http_build_query($details);


//set POST variables
$url = 'http://localhost/TestProjects/vault/test.php';

$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, $str);


//execute post
$result = curl_exec($ch);
echo $result;
//close connection
curl_close($ch);

?>

并在测试php页面代码中: 的print_r($ _ POST);

我和GOT AS

 Array ( [0] => Array ( [news_id] => 126388 [news_title] => ???? ?????? ???? ?????? ????? ???? [news_date] => 2014-11-27 03:17:03 [TAGS] => ????????,?????? [news_detail] => ??? ?????? ??? ??? ????? ???? ?? ???? ?? ????? ??? ??? ?????? ???? ?????? ?????? ?????? ???????? ?? ?? ??????? ????? ??????? ????????? ?? ????? ??? ??? ???? ????? ????? ????? ?? ???? ?? ????? ???? ??????? ???? ????? ??????? ??? ?? ?????? ??? ???? ?? ???? ?????? ???????. ???? ??? ???? ????? ???? ??????? ???? ????? ???? ?????? ????? ???? ????? ????. ???? ???? ?????? ??? ???? ?????? ??????? ?? ??? ????????? ????????? ????? ????????? ??????? ??????? ?????? ??????? ?????????? ??? ?? ??? ??? ??????? ??????? ?????? ?????? ??? ????? ?? ???? ???? ????? ?????????? ??????? ????????? ?? ???? ????? ??????? ??? ???? ??????? ??????? ??????? ??????? ????? ????????? ????????? ??? ??? ????? ???????? ??? ???? ?????? ?? ???? ????????? ?????????. ???? ?????? ??? ??? ????? ???? ?? ???? ?? ????? ??? ??? ?????? ???? ?????? ?????? ?????? ??????? ??????? ???? ????? ????? ?? ????? ???? ????? ????? ? ??????. ?????? ???? ????? ?????? ???????? ???????? ?????? ???? ??????? ??????? ???? ??? ????? ??????? ????????? ?????? ??? ?? ????? ??? ????? ?????? ?? ???? ???? ?????? ??????? ??????? ???????? ???? ????? ?? ????? ????????. ???? ?????? ?? ??? ?? ???? ????? ???????? ??? ???? ??????? ???? ????? ????? ????? ?? ???? ?? ????? ???? ??????? ???? ?????. ????? ?????? ??????? ??? ?????? ?? ??? ?? ???? ???? ???????? ??????? ???????? ??????? ????? ?????? ??? ???? ???? ????? ????? ????? ?? ???? ?? ????? ???? ?????? ????? ????? ?????? ????? ???? ????? ???????? ?????? ????? ????? ???????? ??? ???? ??????? ?? ????? ???? ?? ????? ?? ?????? ??? ???? ????? ???? ????? ??? ?????? ??????? ???? ???????? ??????? ?????? ???? ??????. ????? ???? ????? ?????? ????? ?? ????? ????????? ???? ??? ??? ?????? ??? ?????? ?????? ????????? ?????? ?????? ?????? ???? ??????? ??????? ???? ???? ?? ??? ??????? ???????? ??? ????? ???? ???????? ??????? ??????? ?????? ?????. ???? ???? ?? ??????? ?????? ??? ????? ??? ?? ???? ?? ????? ???? ???? ???? ??????? ???? ????????? ???????? ???? ??????? ????? ????? ???????? ???? ????? ??? ?????. [term_id] => 7 [news_category] => home-news [news_name] => ???????? [news_key] => source [news_source] => ??? ? ?????? [news_image] => http://test.com//wp-content/uploads/ ) ) 

请帮助发布此类数据,以便我可以像发布一样收到它。

2 个答案:

答案 0 :(得分:0)

设置卷曲标题:

$header = array("Content-Type: text/html; charset=UTF-8");
curl_setopt($ch, CURLOPT_HTTPHEADER, $header)

DEMO

header('Content-Type: text/html; charset=UTF-8');
echo file_get_contents("http://www.emaratalyoum.com/multimedia/videos/2012-04-08-1.474873");

答案 1 :(得分:0)

尝试使用对象连接到数据库

define('DB_HOST','localhost');
define('DB_USER','root');
define('DB_PASS','');
define('DB_NAME','lms');
// Establish database connection.
try
{
$dbh = new PDO("mysql:host=".DB_HOST.";dbname=".DB_NAME,DB_USER, 
DB_PASS,array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'"));
}
catch (PDOException $e)
{
exit("Error: " . $e->getMessage());
}

并像这样传递变量

$sql = "select ....."
$query = $dbh->prepare($sql);
$query->execute();

在执行任何SQL行时执行相同的操作