so I've been trying to get the WooCommerce REST API to give me single users and all users information to no avail, I keep getting the error:
{
"code": "woocommerce_rest_cannot_view",
"message": "Sorry, you cannot list resources.",
"data": {
"status": 403
}
}
Using Basic Auth with an https address, the API has both read/write permissions as well.
Using the format of:
https://exampledomain.com/wp-json/wc/v3/customers/
It might be that your server doesn't parse the Authorization header correctly. Try to to send the credentials as query string parameters like this:
https://www.example.com/wp-json/wc/v3/customers?consumer_key=123&consumer_secret=abc
Reset admin and it worked like a charm, weird as hell but yep.
Related
Firstly, this is my Instagram URL after the login:
https://www.instagram.com/oauth/authorize?client_id=$MYCLİENTİD&redirect_uri=https://localhost:4000/İnstagram/Insta.php/&response_type=code&scope=user_profile,user_media
And this is the error that page shows me:
{"error_type": "OAuthException", "code": 400, "error_message": "Invalid redirect_uri"}
When I try to get user token from Instagram, I get that error.
I've tried to change the redirect_uri=(Valid OAuth Redirect URIs), but the error is the same as before.
I could not find this documented anywhere, but through trial and error, I found that the redirect_uri had to:
Use https
Be publicly accessible (e.g. localhost and specifying a port number won't work)
Not include parameters (I found they were getting stripped out, which would cause a redirect_uri mismatch when I later requested an access token)
I had the same problem and I solved it as following:
I first went here:
(remember to change your instagram app id in the below URL)
https://developers.facebook.com/apps/your_instagram_app_id/instagram-basic-display/basic-display/
Then I set my Client OAuth Settings, Deauthorize and Data Deletion Requests as "https://localhost:3000/".
That worked for me.
Actually, for me, it was because my URI was not exactly the same as requested by the app. I forgot to add "/" at the end.
Go to https://developers.facebook.com/apps/APP_ID/instagram-basic-display/basic-display/ -> Client OAuth Settings and put there not just https://localhost:5000, but exact authentication endpoint used in your application (https://localhost:5000/auth or else)
Actually, it does work with localhost, but it is very tedious.
First, you need to have https enabled (which from what I can see from your request you seem to have).
[I don't know if this is mandatory] you need to create a test app* from your main app (https://developers.facebook.com/docs/development/build-and-test/test-apps/)
Set the redirect OAuth URI to something like https://localhost:4000/auth/ and update also all other URIs in .../instagram-basic-display/basic-display/ settings.
Finally, don't forget to use the client-id(or app-id) of the test app in your request, which is different than your parent app
I wish you good luck ;)
*IMPORTANT: app-id and app-secret are different in test app!
As per documentation
Construct the Authorization Window URL below, replacing {app-id} with
your Instagram app’s ID (from the App Dashboard > Products > Instagram
Basic Display > Instagram App ID field) and {redirect-uri} with your website URL that you provided in Step 2 ("Valid OAuth Redirect URIs").
The URL must be exactly the same.
Syntax & Example as below
https://api.instagram.com/oauth/authorize?client_id=<instagram_app_id>&redirect_uri=<my-website>&scope=user_profile,user_media&response_type=code
https://api.instagram.com/oauth/authorize?client_id=00000123&redirect_uri=https://aashutosh-kumar.herokuapp.com/&scope=user_profile,user_media&response_type=code
I am using this solution to select an individual post from a user's feed.
I am using PHP Facebook SDK on the latest version 5.7.
Previously this had worked with no problem, I made my request like:
$response = $this->fb->get(
'/'.$user['id']. '_' .$post_id.'/?fields=id,description,name,full_picture',
$this->get_access_token()
);
And I would get all the fields. However, over the last few months, this has stopped working.
The access_token requests the following permissions:
['user_events', 'user_posts']
I can't find any documentation on the solution outlined in the Stack Overflow post. So I am not sure if I need any more permissions.
I do not get an error when sending this request, I just get the ID back and nothing else. This can be confirmed in the Graph API Explorer:
The v5.0 docs show that when requesting a post I can get full_picture, name and description without mentioning any additional permissions required.
However that same page recommends making the request with just the post ID:
/* PHP SDK v5.0.0 */
/* make the API call */
try {
// Returns a `Facebook\FacebookResponse` object
$response = $fb->get(
'/{post-id}',
'{access-token}'
);
}
Which does not work, you
{
"error": {
"message": "(#12) singular statuses API is deprecated for versions v2.4 and higher",
"type": "OAuthException",
"code": 12,
"fbtrace_id": "ACs2rpwobcW8zSFyL_0Q2yQ"
}
}
The error does mention statuses and not posts but I am not sure how to distinguish the difference between those, I figured they were the same.
Has anyone else stumbled across this and found a solution?
It turns out that the fact it was called status was important. I made a request to the users feed, and noticed that some older posts were returning the data that I needed. I had a look through the list of fields and appended message and type to get the following response:
Not very well documented I guess. But got there in the end, hopefully this can help someone else in future.
I am using Microsoft Graph Library for PHP (microsoftgraph/msgraph-sdk-php) to save documents in Onedrive for Business.
I am having issues to create items (folders or upload files) using Microsoft Graph API, for instance, when I am creating folders I am getting:
"Client error: `POST https://graph.microsoft.com/v1.0/drives/MYDRIVEID/items/MYPARENTFOLDERID/children` resulted in a `400 Bad Request` response: { "error": { "code": "invalidRequest", "message": "One of the provided arguments is not acceptable.", "innerError": { "request-id": "bec1d260-3efd-4417-ba80-96ec37078df6", "date": "2018-07-20T16:48:34" } } } "
POST
https://graph.microsoft.com/v1.0/drives/MYDRIVEID/items/MYPARENTFOLDERID/children
body:
{"name":"Project1","folder":{}}
This is the code I am executing:
$graph->createRequest("POST","/drives/$driveId/items/$itemId/children")-
>attachBody($body)->setReturnType(Model\DriveItem::class)->execute();
My guess is that the API is expecting something different than I am sending, I have tried to change the body, for instance:
{"name":"Project1","folder":{"childCount":0}}
{"name":"Project1","folder":{},"#microsoft.graph.conflictBehavior":"rename"}
{"name":"Project1","folder":{"childCount":0},"#microsoft.graph.conflictBehavior":"rename"}
but I am still getting the same error.
I am not sure what I am doing wrong
Any ideas?
Thanks in advance for your help
I deleted the app registration and registered it again in azure portal. Create folder operation is working as expected.
I am far from the programming and PHP, but got the challenge to get the Fb share count for the website :)
I'm trying to get the proper App Access Token and send the request to Fb
according to this article.
The request should be like this:
https://graph.facebook.com/?ids=http://www.myurl.com/my-page&access_token=myappid|myappsecret
And I getting this error.
{
"error": {
"message": "Invalid OAuth access token signature.",
"type": "OAuthException",
"code": 190,
"fbtrace_id": "FfZKAkCyad1"
}
}
I am going to use it in PHP roughly like this:
function facebook_count($url)
{
$results = #file_get_contents('http://graph.facebook.com/' . $url .'&access_token=myappid|myappsecret');
if ($results) {
$like_array = json_decode($results, true);
if (!empty($like_array['shares']))
return ($like_array['shares']);
}
return 0;
}
My guess, I checked wrong Permissions (scopes) for my App token. Did not found an answer in FB dev page. Checked this for now:
user_likes, read_insights, read_audience_network_insights, public_profile
What Scope do I need to check, if I need only the shares count by the link?
Or in what else could be the problem?
You need to use an App Access Token... So the actual permissions (referring to User Access Tokens!) are irrelevant.
So, hopefully you are replacing myappid|myappsecret with your actual App Id and App Secret. If ynot, there's your error. Furthermore, I think in the file_get_contents call then ?id= part in the URL is missing.
I am getting the following error while using the media/recent API.
{
"meta": {
"error_type": "APINotAllowedError",
"code": 400,
"error_message": "This tag cannot be viewed"
}
}
I have tried with client Id and access token.
https://api.instagram.com/v1/tags/mytag/media/recent?client_id=clientId
or
https://api.instagram.com/v1/tags/mytag?access_token=accesstokem
Also, I created new App in different Instagram account and tried. It gives me the same error.
Only for particular hashtag I am getting this error, for other hashtags I am getting the proper response.
Please help me.