2017-11-21 18 views
0

私はRestAPIを使用してwordpressでページを作成しようとしています。 URL:/ WP-JSON/WP/V2 /ページ タイプ:ポスト、 リクエストPARMS:RestAPIを使用してwordPressでページを作成する方法

{"date":"2017-11-08 03:01:46","date_gmt":"2017-11-08 03:01:46","slug,status":"woo","password":"W47lFMylD9u3q&WUln","parent":"1","title":"new","content":"test","author":1,"excerpt":"1","featured_media":"1","comment_status":"open","ping_status":"open","menu_order":"1","meta":[],"template":"template-homepage.php"} 

しかし、それは

{ 
"code": "rest_cannot_edit_others", 
"message": "Sorry, you are not allowed to create posts as this user.", 
"data": { 
    "status": 401 
} 
} 

私はAPIをチェックするためのポストマンを使用しています。このエラーを示しますどこで基本、oauth1.0とoauth 2.0のautenticationで与えられたが動作していない私のWordPressのAPIキーを与える。誰でもこの問題を助けることができますか?

+0

を試してみてください。 –

+0

変更されました@RoolPaap –

+0

チェックソリューションリンク: - https://stackoverflow.com/questions/47430162/displaying-rest-api-data-in-angular-from-wordpress-woocommerce/47430518#47430518 –

答えて

0

あなたは二度とない要求エラーを追加しました、例の下

<?php 
 
/** 
 
* Template Name: Rest API Page 
 
* 
 
* @link https://codex.wordpress.org/Template_Hierarchy 
 
* 
 
* @package WordPress 
 
* @subpackage Twenty_Seventeen 
 
* @since 1.0 
 
* @version 1.0 
 
*/ 
 

 
?> 
 

 
<?php 
 
\t //echo "SELECT * FROM $wpdb->posts where post_type = 'post' "; 
 
\t $posts = $wpdb->get_results("SELECT * FROM $wpdb->posts where post_type = 'post' AND post_status = 'publish'"); 
 

 
\t $items = array(); 
 
\t foreach ($posts as $post) { 
 
\t \t $item['title'] \t = get_the_title($post->ID); 
 
\t \t $item['url'] \t \t = get_permalink($post->ID); 
 
\t \t $item['desc'] \t = $post->excerpt; 
 
\t \t $item['image'] \t = wp_get_attachment_url(get_post_thumbnail_id($post->ID)); 
 
\t \t $item['thumb'] \t = get_post_meta($post->ID, 'Thumbnail', true); 
 
\t \t $items[] \t \t \t \t = $item; 
 
\t \t // \t $result[] = array('post_title'=>$post_title); 
 
\t } 
 
\t header('Content-Type: application/json'); 
 
\t echo json_encode(array('posts'=>$items)); 
 

 
?>

+0

私は投稿やポスト値を取得しないように動的にAPIを使用してWordPressでページ: –

+0

@RaghulRajendran、現在私も同じように取り組んでいます。私が解決策を得るなら、私はあなたと共有します... :) –

関連する問題