Want to push posts through WP-API wordpressWhat does '--user' mean with curlWP REST API How to upload featured image?Can I install/update WordPress plugins without providing FTP access?WordPress plugin accessing WordPress URL remotely to send data acrossShopify Receipt and refund button grayed outwordpress REST API draft posts not showingUsing Contact Form 7 via WP REST APIWordPress Rest API get All PostsWordPress Rest API get total post countWordpress Multisite - API posts return an empty arrayPosting with Wordpress API RESTExtend post object in REST api in wordpress

Does an advisor owe his/her student anything? Will an advisor keep a PhD student only out of pity?

I am looking for the correct translation of love for the phrase "in this sign love"

Where does the bonus feat in the cleric starting package come from?

What is Cash Advance APR?

On a tidally locked planet, would time be quantized?

What is the evidence for the "tyranny of the majority problem" in a direct democracy context?

Freedom of speech and where it applies

Aragorn's "guise" in the Orthanc Stone

Fear of getting stuck on one programming language / technology that is not used in my country

Count the occurrence of each unique word in the file

How much character growth crosses the line into breaking the character

Why electric field inside a cavity of a non-conducting sphere not zero?

Store Credit Card Information in Password Manager?

why `nmap 192.168.1.97` returns less services than `nmap 127.0.0.1`?

Why should universal income be universal?

How do you respond to a colleague from another team when they're wrongly expecting that you'll help them?

Why did the EU agree to delay the Brexit deadline?

When a Cleric spontaneously casts a Cure Light Wounds spell, will a Pearl of Power recover the original spell or Cure Light Wounds?

How to explain what's wrong with this application of the chain rule?

If a character has darkvision, can they see through an area of nonmagical darkness filled with lightly obscuring gas?

What prevents the use of a multi-segment ILS for non-straight approaches?

Biological Blimps: Propulsion

Yosemite Fire Rings - What to Expect?

Is this toilet slogan correct usage of the English language?



Want to push posts through WP-API wordpress


What does '--user' mean with curlWP REST API How to upload featured image?Can I install/update WordPress plugins without providing FTP access?WordPress plugin accessing WordPress URL remotely to send data acrossShopify Receipt and refund button grayed outwordpress REST API draft posts not showingUsing Contact Form 7 via WP REST APIWordPress Rest API get All PostsWordPress Rest API get total post countWordpress Multisite - API posts return an empty arrayPosting with Wordpress API RESTExtend post object in REST api in wordpress













1















Greeting of the day,
I want to publish posts through an API call in wordpress without using the admin panel, i have used the http-auth plugin to manage the authorization into wordpress, also change the .htaccess file with the below code:



RewriteCond %HTTP:Authorization ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]


and my script is this:



<?php
$process = curl_init('http://somewhereinsouth.com/wp-json/wp/v2/posts');
$data = array('slug' => 'welcome-to-the-jungle' , 'title' => 'Welcome to the Jungle' , 'content' => 'We welcome to you a better journey at the jungle.', 'excerpt' => 'smaller' );
$data_string = json_encode($data);
$headers = array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string),
'Authorization' .'Basic'.base64_encode('admin:Best@xy123'));
// create the options starting with basic authentication
// curl_setopt($process, CURLOPT_USERPWD, $username . ":" . $password);
curl_setopt($process, CURLOPT_TIMEOUT, 30);
curl_setopt($process, CURLOPT_POST, 1);
// make sure we are POSTing
curl_setopt($process, CURLOPT_CUSTOMREQUEST, "POST");
// this is the data to insert to create the post
curl_setopt($process, CURLOPT_POSTFIELDS, $data_string);
// allow us to use the returned data from the request
curl_setopt($process, CURLOPT_RETURNTRANSFER, TRUE);
// we are sending json
curl_setopt($process, CURLOPT_HTTPHEADER, $headers);
// process the request
$return = curl_exec($process);
curl_close($process);
// This buit is to show you on the screen what the data looks like returned and then decoded for PHP use
echo '<h2>Results</h2>';
print_r($return);
echo '<h2>Decoded</h2>';
$result = json_decode($return, true);
print_r($result);


And now i getting following Error while posting the posts at my website using this script. Error:



<h2>Results</h2><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>BestViewsReviews | Restricted Site</title>
<link rel="stylesheet" href="http://somewhereinsouth.com/wp-content/plugins/http-auth/frontend/css/style.min.css" type="text/css">
</head>
<body class="http-restricted">
<p>You are not allowed to perform this action.</p>
</body>
</html><h2>Decoded</h2>


Please help me into this, thanks in advanced.










share|improve this question






















  • Can you try pass your admin:password as a curl --user rather than a header, see more here on --user stackoverflow.com/questions/36292406/…

    – designtocode
    Mar 8 at 7:19











  • can you please share snippet, how to use --user in above code.

    – Manish Agarwal
    Mar 8 at 8:31












  • You have commented out CURLOPT_USERPWD, did this not work?

    – designtocode
    Mar 8 at 8:53











  • i have solved this, can you please tell me know if you can suggest how to add feature images into post through the API.

    – Manish Agarwal
    Mar 8 at 10:49











  • You need to pass the image in a different endpoint i.e. /wp-json/wp/v2/media and attach it to the post id. Read more here stackoverflow.com/questions/33103707/…

    – designtocode
    Mar 8 at 13:15















1















Greeting of the day,
I want to publish posts through an API call in wordpress without using the admin panel, i have used the http-auth plugin to manage the authorization into wordpress, also change the .htaccess file with the below code:



RewriteCond %HTTP:Authorization ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]


and my script is this:



<?php
$process = curl_init('http://somewhereinsouth.com/wp-json/wp/v2/posts');
$data = array('slug' => 'welcome-to-the-jungle' , 'title' => 'Welcome to the Jungle' , 'content' => 'We welcome to you a better journey at the jungle.', 'excerpt' => 'smaller' );
$data_string = json_encode($data);
$headers = array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string),
'Authorization' .'Basic'.base64_encode('admin:Best@xy123'));
// create the options starting with basic authentication
// curl_setopt($process, CURLOPT_USERPWD, $username . ":" . $password);
curl_setopt($process, CURLOPT_TIMEOUT, 30);
curl_setopt($process, CURLOPT_POST, 1);
// make sure we are POSTing
curl_setopt($process, CURLOPT_CUSTOMREQUEST, "POST");
// this is the data to insert to create the post
curl_setopt($process, CURLOPT_POSTFIELDS, $data_string);
// allow us to use the returned data from the request
curl_setopt($process, CURLOPT_RETURNTRANSFER, TRUE);
// we are sending json
curl_setopt($process, CURLOPT_HTTPHEADER, $headers);
// process the request
$return = curl_exec($process);
curl_close($process);
// This buit is to show you on the screen what the data looks like returned and then decoded for PHP use
echo '<h2>Results</h2>';
print_r($return);
echo '<h2>Decoded</h2>';
$result = json_decode($return, true);
print_r($result);


And now i getting following Error while posting the posts at my website using this script. Error:



<h2>Results</h2><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>BestViewsReviews | Restricted Site</title>
<link rel="stylesheet" href="http://somewhereinsouth.com/wp-content/plugins/http-auth/frontend/css/style.min.css" type="text/css">
</head>
<body class="http-restricted">
<p>You are not allowed to perform this action.</p>
</body>
</html><h2>Decoded</h2>


Please help me into this, thanks in advanced.










share|improve this question






















  • Can you try pass your admin:password as a curl --user rather than a header, see more here on --user stackoverflow.com/questions/36292406/…

    – designtocode
    Mar 8 at 7:19











  • can you please share snippet, how to use --user in above code.

    – Manish Agarwal
    Mar 8 at 8:31












  • You have commented out CURLOPT_USERPWD, did this not work?

    – designtocode
    Mar 8 at 8:53











  • i have solved this, can you please tell me know if you can suggest how to add feature images into post through the API.

    – Manish Agarwal
    Mar 8 at 10:49











  • You need to pass the image in a different endpoint i.e. /wp-json/wp/v2/media and attach it to the post id. Read more here stackoverflow.com/questions/33103707/…

    – designtocode
    Mar 8 at 13:15













1












1








1








Greeting of the day,
I want to publish posts through an API call in wordpress without using the admin panel, i have used the http-auth plugin to manage the authorization into wordpress, also change the .htaccess file with the below code:



RewriteCond %HTTP:Authorization ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]


and my script is this:



<?php
$process = curl_init('http://somewhereinsouth.com/wp-json/wp/v2/posts');
$data = array('slug' => 'welcome-to-the-jungle' , 'title' => 'Welcome to the Jungle' , 'content' => 'We welcome to you a better journey at the jungle.', 'excerpt' => 'smaller' );
$data_string = json_encode($data);
$headers = array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string),
'Authorization' .'Basic'.base64_encode('admin:Best@xy123'));
// create the options starting with basic authentication
// curl_setopt($process, CURLOPT_USERPWD, $username . ":" . $password);
curl_setopt($process, CURLOPT_TIMEOUT, 30);
curl_setopt($process, CURLOPT_POST, 1);
// make sure we are POSTing
curl_setopt($process, CURLOPT_CUSTOMREQUEST, "POST");
// this is the data to insert to create the post
curl_setopt($process, CURLOPT_POSTFIELDS, $data_string);
// allow us to use the returned data from the request
curl_setopt($process, CURLOPT_RETURNTRANSFER, TRUE);
// we are sending json
curl_setopt($process, CURLOPT_HTTPHEADER, $headers);
// process the request
$return = curl_exec($process);
curl_close($process);
// This buit is to show you on the screen what the data looks like returned and then decoded for PHP use
echo '<h2>Results</h2>';
print_r($return);
echo '<h2>Decoded</h2>';
$result = json_decode($return, true);
print_r($result);


And now i getting following Error while posting the posts at my website using this script. Error:



<h2>Results</h2><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>BestViewsReviews | Restricted Site</title>
<link rel="stylesheet" href="http://somewhereinsouth.com/wp-content/plugins/http-auth/frontend/css/style.min.css" type="text/css">
</head>
<body class="http-restricted">
<p>You are not allowed to perform this action.</p>
</body>
</html><h2>Decoded</h2>


Please help me into this, thanks in advanced.










share|improve this question














Greeting of the day,
I want to publish posts through an API call in wordpress without using the admin panel, i have used the http-auth plugin to manage the authorization into wordpress, also change the .htaccess file with the below code:



RewriteCond %HTTP:Authorization ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]


and my script is this:



<?php
$process = curl_init('http://somewhereinsouth.com/wp-json/wp/v2/posts');
$data = array('slug' => 'welcome-to-the-jungle' , 'title' => 'Welcome to the Jungle' , 'content' => 'We welcome to you a better journey at the jungle.', 'excerpt' => 'smaller' );
$data_string = json_encode($data);
$headers = array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string),
'Authorization' .'Basic'.base64_encode('admin:Best@xy123'));
// create the options starting with basic authentication
// curl_setopt($process, CURLOPT_USERPWD, $username . ":" . $password);
curl_setopt($process, CURLOPT_TIMEOUT, 30);
curl_setopt($process, CURLOPT_POST, 1);
// make sure we are POSTing
curl_setopt($process, CURLOPT_CUSTOMREQUEST, "POST");
// this is the data to insert to create the post
curl_setopt($process, CURLOPT_POSTFIELDS, $data_string);
// allow us to use the returned data from the request
curl_setopt($process, CURLOPT_RETURNTRANSFER, TRUE);
// we are sending json
curl_setopt($process, CURLOPT_HTTPHEADER, $headers);
// process the request
$return = curl_exec($process);
curl_close($process);
// This buit is to show you on the screen what the data looks like returned and then decoded for PHP use
echo '<h2>Results</h2>';
print_r($return);
echo '<h2>Decoded</h2>';
$result = json_decode($return, true);
print_r($result);


And now i getting following Error while posting the posts at my website using this script. Error:



<h2>Results</h2><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>BestViewsReviews | Restricted Site</title>
<link rel="stylesheet" href="http://somewhereinsouth.com/wp-content/plugins/http-auth/frontend/css/style.min.css" type="text/css">
</head>
<body class="http-restricted">
<p>You are not allowed to perform this action.</p>
</body>
</html><h2>Decoded</h2>


Please help me into this, thanks in advanced.







wordpress wordpress-rest-api






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 8 at 5:04









Manish AgarwalManish Agarwal

287




287












  • Can you try pass your admin:password as a curl --user rather than a header, see more here on --user stackoverflow.com/questions/36292406/…

    – designtocode
    Mar 8 at 7:19











  • can you please share snippet, how to use --user in above code.

    – Manish Agarwal
    Mar 8 at 8:31












  • You have commented out CURLOPT_USERPWD, did this not work?

    – designtocode
    Mar 8 at 8:53











  • i have solved this, can you please tell me know if you can suggest how to add feature images into post through the API.

    – Manish Agarwal
    Mar 8 at 10:49











  • You need to pass the image in a different endpoint i.e. /wp-json/wp/v2/media and attach it to the post id. Read more here stackoverflow.com/questions/33103707/…

    – designtocode
    Mar 8 at 13:15

















  • Can you try pass your admin:password as a curl --user rather than a header, see more here on --user stackoverflow.com/questions/36292406/…

    – designtocode
    Mar 8 at 7:19











  • can you please share snippet, how to use --user in above code.

    – Manish Agarwal
    Mar 8 at 8:31












  • You have commented out CURLOPT_USERPWD, did this not work?

    – designtocode
    Mar 8 at 8:53











  • i have solved this, can you please tell me know if you can suggest how to add feature images into post through the API.

    – Manish Agarwal
    Mar 8 at 10:49











  • You need to pass the image in a different endpoint i.e. /wp-json/wp/v2/media and attach it to the post id. Read more here stackoverflow.com/questions/33103707/…

    – designtocode
    Mar 8 at 13:15
















Can you try pass your admin:password as a curl --user rather than a header, see more here on --user stackoverflow.com/questions/36292406/…

– designtocode
Mar 8 at 7:19





Can you try pass your admin:password as a curl --user rather than a header, see more here on --user stackoverflow.com/questions/36292406/…

– designtocode
Mar 8 at 7:19













can you please share snippet, how to use --user in above code.

– Manish Agarwal
Mar 8 at 8:31






can you please share snippet, how to use --user in above code.

– Manish Agarwal
Mar 8 at 8:31














You have commented out CURLOPT_USERPWD, did this not work?

– designtocode
Mar 8 at 8:53





You have commented out CURLOPT_USERPWD, did this not work?

– designtocode
Mar 8 at 8:53













i have solved this, can you please tell me know if you can suggest how to add feature images into post through the API.

– Manish Agarwal
Mar 8 at 10:49





i have solved this, can you please tell me know if you can suggest how to add feature images into post through the API.

– Manish Agarwal
Mar 8 at 10:49













You need to pass the image in a different endpoint i.e. /wp-json/wp/v2/media and attach it to the post id. Read more here stackoverflow.com/questions/33103707/…

– designtocode
Mar 8 at 13:15





You need to pass the image in a different endpoint i.e. /wp-json/wp/v2/media and attach it to the post id. Read more here stackoverflow.com/questions/33103707/…

– designtocode
Mar 8 at 13:15












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55057017%2fwant-to-push-posts-through-wp-api-wordpress%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid …


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55057017%2fwant-to-push-posts-through-wp-api-wordpress%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Thal And Out Agency railway station See also References External links Navigation menuOfficial Web Site of Pakistan RailwaysArchivedOfficial Web Site of Pakistan Railwayseeexpanding ite

How can I change the color of pagination dots of UIPageControl?How to change UIPageControl dotsIs there a way to change page indicator dots colorCustomize dot with image of UIPageControl at index 0 of UIPageControlNo visible @interface for 'NSObject<PageControlDelegate>' declares the selector 'pageControlPageDidChange:'How to change the color of pagination dots in UIPageControl with a different color per pagepagecontrol indicator custom image instead of DefaultChanging the colour of UIPageControl dots in MonoTouchpagecontrol selectable page visibility color?Alternative way to load ViewControllers on a UIPageControlHow to set only layer.border-color for UIpage control dots in swiftHow can I develop for iPhone using a Windows development machine?How to change the name of an iOS app?UITableView - change section header coloruipagecontrol indicator(dot)issueCustom UIPageControl dots color not changingchange the interspace between UIPageControl dotsHow to change Status Bar text color in iOSHow can I change image tintColor in iOS and WatchKitUIPageControl dots with larger space in between each dotsHow to change the color of pagination dots in UIPageControl with a different color per page

Posting a File and Associated Data to a RESTful WebService preferably as JSON2019 Community Moderator ElectionREST URI convention - Singular or plural name of resource while creating itUploading both data and files in one form using Ajax?How do I upload a file with metadata using a REST web service?REST API - file (ie images) processing - best practicesSpring: JSON data and file in the same requestREST API Put large dataPosting a file and JSON data to Spring rest serviceRESTful Web Service Upload/Download Large Data With JSONREST API Design sending JSON data and a file to the api in same requestPost JSONArray to REST servicePUT vs. POST in RESTParsing values from a JSON file?JavaScript/jQuery to download file via POST with JSON dataHow do I upload a file with metadata using a REST web service?How to POST JSON data with Curl from Terminal/Commandline to Test Spring REST?Separate REST JSON API server and client?what's the correct way to send a file from REST web service to client?How do I write JSON data to a file?What is “406-Not Acceptable Response” in HTTP?REST API - file (ie images) processing - best practices