Why would the same FB insights query work in a browser and Graph API Explorer, but return null with PHP SDK? - facebook-graph-api

As you can see in this picture
I have a valid long-life Access Token for my app (390068587730802) with the following permissions: ads_management, manage_pages, read_insights, user_friends
I can use it to get data on another accessible app (50813163906) using the Graph API Explorer,
$facebook->getUser(); does return my user id
HOWEVER, I get NULL from the same request via the PHP SDK.
I have tested locally on xampp and on an apache server. I have updated the PHP SDK today to include the latest changes surrounding offline_access and long life tokens. I have read dozens of posts and FB documentation. I´m glad to read more you think will help, but please note that my token is valid, long lived, and I am successfully getting "/me" from the graph API. All of this happens under http or https.
UPDATE "Facebook: Sorry, something went wrong. We're working on getting this fixed as soon as we can."
As seen in this next picture below, I´ve var_dump´d the CURL options to verify the correct access_token and URL is actually being called. Furthermore, I can copy these urls directly into the browser and get complete data return!!
If during my testing I have created "two active sessions" - as some docs warn - how can you test for that? Most importantly, why would the same FB insights query work in the Graph API Explorer, but return null with PHP SDK?

It turns out that "since=30 days ago" was giving a 400 (bad request) response. This error was not showing up in the CURL errors. Only via
curl_getinfo($this -> ch,CURLINFO_HTTP_CODE);
When i changed
$period = "{$period} days ago";
to
$period = urlencode("{$period} days ago");
//or
$period = strtotime("- {$period} days");
everything worked via CURL.

Related

Tapkey Web API - Problem when Registering OAuth clients [Tapkey]

I am trying to register OAuth client, following the docs, but none of the links containing /developers in the path are working for me. I am either getting redirected to the https://my.tapkey.com/AdminUI/ and infinite load, until i refresh the page, or getting status code 502 Bad Gateway.
The ones I am having problems with are:
https://my.tapkey.com/AdminUI/developers/oauth-clients
https://my.tapkey.com/AdminUI/developers/identity-providers.
I tried on different OS's, using proxy, but nothing worked for me.
I am trying to register OAuth client, and explore more of the TapKey web api, but this one is a blocker for me.
You caught us here - we have changed the website a bit, and updated documentation is on its way but not yet published. We are working on it right now.
Developer section has moved to Tapkey Integrator Portal available on https://portal.tapkey.io .
Use the same login credentials you are using with Tapkey.

Getting 401 from Netsuite REST API

I'm following this tutorial here to attempt to authenticate using Token Based Authentication with Netsuite:
through postman using Netsuite's Postman environment, but I continue to receive "401 Invalid login attempt".
When I check the Login Audit Trail, I see that there is no role being assigned to my authentication attempts -- it's just blank. To me, this indicates that the token is not properly assigned to the User/Role, but I've walked through the directions several times and everything appears to be setup properly.
I've seen other similar posts about this, but those seem to boil down to the Netsuite Account ID formatting. However, my Netsuite Account ID is all numbers, so I don't think this is a factor.
This should work fine assuming you have created an integration and an access token. Configure Oauth 1.0 in postman with the following fields filled out correctly:
signature method (should be HMAC-256)
consumer key (from the integration you created in netsuite)
consumer secret (from the integration you created in netsuite)
access token (from the access token created in netsuite)
token secret (from the access token created in netsuite)
realm (your account id, if using a sandbox, make sure the realm looks like 1234567_SB1, with an _ and not a -)
You won't be able to complete TBA using postman because using netsuite TBA requires a callback URL that netsuite will redirect you to with the necessary credentials (access token and & token secret).
I'm having this exact same issue. I have custom code written in Salesforce APEX that is connecting to NetSuite just fine. We also have a Workato integration that is connecting to NetSuite just fine.
No matter what I do in Postman, I get a 401 Invalid Login response. I'm losing my mind...
I finally got this to work for me. Postman had a request header of "Connection"="keep-alive". Once I removed that it worked fine! Wow.. I've been trying to get this to work for weeks, looking at it every few days for an hour or two. What a frustrating error message "Invalid Login".

Facebook auth setup

How can I setup PAW to work with Facebook locally for development? Or even at all for that matter?
I have a node.js backend that I'm setting up with Facebook Auth. Every one of my routes needs the user to be logged in. I have two endpoints related to FB Auth. localhost:3000/api/v1/loginFB and localhost:3000/api/v1/callbackFB. Both of these work great in a web browser.
loginFB simply returns this string... https://www.facebook.com/dialog/oauth?client_id=523534457345&redirect_uri=https://localhost:3000/api/v1/callbackFB&scope=email,public_profile,user_friends.
When I call that URI in a browser, it returns a code=blahblah which my callbackFB endpoint uses to fire off another request to get the access token. All good.
So now in PAW I'm confused by the difference between the request URI and the Authorization URL text field? Should I use the loginFB URI for my request URI? And then https://www.facebook.com/dialog/oauth in the Authorization URL textfield?
Basically what's happening is that when I click Get Access Token, it returns the code but my callbackFB endpoint 500's by saying "This authorization code has been used." The code that it's getting returned is definitely different each time I Get Access Token.
This is where I'm at with this thing (Client ID and Client Secret are actually my App ID and App Secret from fb's dev management site, and the Access Token URL is actually set to https://graph.facebook.com/v2.3/oauth/access_token which I'm 99% sure is the correct URI):
This is the error I get when I click Get Access Token button:
It would be awesome to get some advice from anyone with experience with this issue. Thanks.
Re: #MichaMazaheri
tl;dr Fixed in version 2.2.2
Sorry for the super late follow-up. We actually fix this exact issue in Paw 2.2.2, which is already released on our website, and pending review for the Mac App Store. (It was some JSON vs. Form URL-Encoded parsing issue). Thanks for reporting.

Page Login access tokens

I have been using the api and in the past the call to get a list of pages would return a page access_token string with pipes (|). Just like this image:
http://developers.facebook.com/attachment/page_tokens.png
Now after upgrading to the new sdk it is returned like this:
AAAD4IFCrso0BAIIaDhBIfadsavdasifIjTleB9Fu92pAYzfBbYXIxdzm9cFZBgZBrNjI0KSKOqCzw2kQCzu1hra2owH4fX5youiNtRrBzlweM3aZDZD
// Not a real token
The problem is now I can't seem to publish events to pages. All sites I have that are setup with the old access_token works fine.
Does anybody if this is a change that hasn't been talked about or am I missing something?
This is part of the OAuth 2.0 and HTTPS migration that has been mentioned many times on the Facebook developer blog and Facebook Roadmap. All access_tokens will be sent encrypted (no pipes). They will and do work like normal tokens, unless you were doing some kind of parsing of the tokens which is no longer possible.

Getting "This method must be called with an app access_token" adding test users via graph api

I'm trying to create Facebook test accounts using the graph API. (I need to be able to log into them from my iphone app). Here's how I'm getting the app access token:
https://graph.facebook.com/oauth/access_token?grant_type=client_credentials&client_id=MY-CLIENT-ID&client_secret=MY-CLIENT-SECRET
which seems to work fine. And here's how I'm trying to create a user:
https://graph.facebook.com/MY-APP-ID/accounts/test-users?installed=true&name=TestUser1&permissions=read_stream&method=post&access_token=MY-APP-ACCESS-TOKEN
The response I'm getting is:
This method must be called with an app access_token
I looked at this post Problem with access token while creating Facebook Test Users. Not really familiar with PHP, and just to make sure, I did try to "url encode" the app access token returned before using it... but no goodness.
I'm using Fiddler to test my posts.
Thanks!
Facebook doesn't support test users for Native Mobile App
see related bug on bugzilla
http://bugs.developers.facebook.net/show_bug.cgi?id=17779
hope this helps
Did you remove the 'access_token=' part from access token that's returned from the first request? If not, then you'll have an incorrect request on the second call, since the URL will have 'access_token=' twice.