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

Understanding generators in Python2019 Community Moderator ElectionGenerator function not working pythonFor loop not executing two timesGenerators - Printing generated valuesWhy can a python generator only be used once?What exactly do generators do?What does the “yield” keyword do?What does “list comprehension” mean? How does it work and how can I use it?sklearn Kfold acces single fold instead of for loopIs a generator the callable? Which is the generator?Apply Border To Range Of Cells Using OpenpyxlCalling an external command in PythonWhat are metaclasses in Python?What is the difference between @staticmethod and @classmethod?Finding the index of an item given a list containing it in PythonDifference between append vs. extend list methods in PythonHow can I safely create a nested directory in Python?Does Python have a ternary conditional operator?Understanding slice notationUnderstanding Python super() with __init__() methodsDoes Python have a string 'contains' substring method?

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