Get facebook page access_token appcelerator arg missing - facebook-graph-api

I have this for trying to get page access token from facebook.
I am doing this with appcelerator titanium.
Ti.Facebook.requestWithGraphPath(Titanium.App.Properties.getString("sidnamn"), {fields: 'access_token'}, function(resp) {
if(resp.access_token) {
Ti.API.info(resp.access_token);
} });
When i run this i get this error:
message = "Invalid number of arguments to function. expected 4 arguments, received: 3 in -[FacebookModule requestWithGraphPath:] (FacebookModule.m:440)";
So what have i missed?

argument one = target
argument two = data
argument three = method (POST/GET)
argument four = callback
My answer does not address the quality of your target or data, but that your 3rd argument is NOT POST/GET

Related

Nested pagination in facebook graph api while using php-sdk-v4

I am trying to get all users who likes a specific post on a feed. I am using facebook/php-sdk-v4 . There is no problem on getting next page for feed. However when I use next function to get next users who liked that post in inner loop it gives
Error:Caused by: Facebook\Exceptions\FacebookAuthenticationException
Subfields are not supported by feed.
In FacebookRequest.php I disabled appsecret_proof, maybe it is related to this security issue. If I don't disable, it gives now invalid appsecret_proof despite v5.0 sdk already generates appsecret_proof internally at the line 70 of Facebook\Authentication\AccessToken.php.
Without appsecret_proof I am able to request but in some cases like batch query or loops I think there is a need for appsecret_proof. However, it generates that code itself and it gives invalid error. I don't know what to do.
$fb = new Facebook\Facebook([
'app_id' => '60...
]);
$feed = $graphNode->getField('feed')
while(true) {
foreach ($feed->all() as $key1 => $post) {
if ($likes = $post->getField('likes')){
while(true) {
if (!($likes = $fb->next($likes))) break;
}
}
}
if (!($feed = $fb->next($feed))) break;
}

call_user_func() expects parameter 1 to be a valid callback - Laravel unit testing

I am testing an API that returns a JOSN object, while running the following:
public function testBasicExample()
{
$response = $this->call('GET', 'sites/1/webmaster/totalstats?since=2014-01-01&until=2014-12-30');
}
getting error:
There was 1 error:
1) ExampleTest::testBasicExample ErrorException: call_user_func()
expects parameter 1 to be a valid callback, no array or string given
/var/www/html/laravel/app/facade/Webmaster.php:527
/var/www/html/laravel/app/helpers/WebmasterHelper.php:100
/var/www/html/laravel/app/controllers/WebmasterController.php:129
/var/www/html/laravel/app/routes.php:73
/var/www/html/laravel/vendor/laravel/framework/src/Illuminate/Routing/Route.php:109
/var/www/html/laravel/vendor/laravel/framework/src/Illuminate/Routing/Router.php:1033
/var/www/html/laravel/vendor/laravel/framework/src/Illuminate/Routing/Router.php:1001
/var/www/html/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:775
/var/www/html/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:745
/var/www/html/laravel/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Client.php:81
/var/www/html/laravel/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Client.php:327
/var/www/html/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Testing/ApplicationTrait.php:51
/var/www/html/laravel/app/tests/ExampleTest.php:16
FAILURES! Tests: 1, Assertions: 0, Errors: 1.
I just started laravel a few days ago so I might do some very basic mistakes. Please help. Thanks
Assuming that you're trying to send a GET request at that endpoint, you're using the wrong method.
Try this:
public function testBasicExample()
{
$response = $this->get('/sites/1/webmaster/totalstats?since=2014-01-01&until=2014-12-30');
}
Then you'll probably want to make use of one of Laravel's built-in JSON-testing methods: https://laravel.com/docs/5.6/http-tests#testing-json-apis
you might want to do this way
$response = $this->call('GET', 'sites/1/webmaster/totalstats', [
'since' => '2014-01-01',
'until' => '2014-12-30'
]);
input parameters will place as the 3rd parameters, you might give it a try.

facebook pagination next url giving empty set of friend list

i am using following code to get all my friends ,but it gives only 5 friends in data and next pagination link,i have 22 friends but when i click on next pagination gives empty array data
FB.api('/me/friends/?access_token=CAACEdEose0cBAIgrQyQs6DaApZAwDCpSub2WHKXaU3inS1QPvcep24avZCoVpyYcHoWgZBltVdFKbKy8UokU6x2JXGEgeDcRu3C3sM2dEZCuzQIsbZALFGPcamyRqR5ZA4VE8c0U2KNcKNar5qVzo9ToAr6BQatoJKd4dIiXg3dqoS4RLlszQjfm3Yf66XxtKxPyIHEDhudQCLgBZCcINLlucERa4ZBf9a8ZD',function(response) {
console.log(response);
if (response && !response.error) {
var nextPage = response.paging.next;
FB.api('v2.1/248176728710033/friends?limit=10&access_token=CAACEdEose0cBAIgrQyQs6DaApZAwDCpSub2WHKXaU3inS1QPvcep24avZCoVpyYcHoWgZBltVdFKbKy8UokU6x2JXGEgeDcRu3C3sM2dEZCuzQIsbZALFGPcamyRqR5ZA4VE8c0U2KNcKNar5qVzo9ToAr6BQatoJKd4dIiXg3dqoS4RLlszQjfm3Yf66XxtKxPyIHEDhudQCLgBZCcINLlucERa4ZBf9a8ZD&offset=10&__after_id=enc_AeysBhpBnD6OYeeb4OHHT4qPay7GeUF8OUqNU7PcF3HilkONx4E5EXzymARn2J3u7msA2J4PqjbJyyCE51vHJCOX',function(resp){
console.log(resp);
});
}
//
});
It is not possible to get ALL friends anymore, see my answer in this thread: how to get a list of all user friends (not only who use the app)?
If you still get friends who aren´t using your App, it could be because your App was created before end of April 2014. In that case, it´s a v1.0 App. Your are using /me/friends without a version tag in the first call, but with a version tag in the second call. Also, use /me instead of that id (248176728710033).

facebookclient.post() or .posttaskasync() with .net sdk returns invalid parameter when trying to post a link

I've had this working in a previous version of my application and I tried using the old code, but I think the new sdk has something different going on. I'm simply trying to post a link (that includes an image) to my wall and receiving an "Invalid Parameter" response.
Here is the relevant code (I've also tried PostTaskAsync()...same result):
var client = new FacebookClient(accessToken);
var postParams = new
{
name = "the name",
caption = "the caption",
description = "the description",
link = "http://www.example.com/",
picture = "http://www.example.com/uploadedimages/myimage.jpg"
};
client.Post("me/feed", postParams);
I've tried substituting the object with a Dictionary with the same result. I've tried substituting object with dynamic parameters = new ExpandoObject(); with the same result.
If I post the object with just { message = "this is a test message" } it posts fine so I know that I have permissions to post on my wall. Something just isn't jiving when I try to post the link with the image. I also tried urlencoding the link and the image url and received a different error indicating that the "link/picture URL is not properly formatted".
I stripped out all of the parameters thinking one of them was no longer supported, but still no dice.
Here is the exact exception being thrown:
Facebook.FacebookApiException: (FacebookApiException - #100) Invalid
parameter at Facebook.FacebookClient.ProcessResponse(HttpHelper
httpHelper, String responseString, Type resultType, Boolean
containsEtag, IList`1 batchEtags) at
Facebook.FacebookClient.Api(HttpMethod httpMethod, String path, Object
parameters, Type resultType) at Facebook.FacebookClient.Post(String
path, Object parameters)
I got this sorted out. It turns out the link and the image url have to be in the same domain as the app you're using to post.
EDIT: just to clarify. The domain has to be included in your app's config section (on Facebook) in the "App domains" section at the top.

Scala Play2 Error on Web Service call

I'm getting an error on compile with the following code.
I'm trying to call a Web Service.
def authenticate(username: String, password: String): String = {
val request: Future[Response] =
WS.url(XXConstants.URL_GetTicket)
.withTimeout(5000)
.post( Map("username" -> Seq(username), "password" -> Seq(password) ) )
request map { response =>
Ok(response.xml.text)
} recover {
case t: TimeoutException =>
RequestTimeout(t.getMessage)
case e =>
ServiceUnavailable(e.getMessage)
}
}
I'm seeing the following compiler error:
type mismatch; found : scala.concurrent.Future[play.api.mvc.SimpleResult[String]] required: String
The value being returned from your authenticate function is val request = ... which is of type Future[Response] but the function expects a String which as the compiler says is a type mismatch error. Changing the return type of the function to Future[Response] or converting request to a String before returning it should fix it.
Like say Brian, you're currently returning a Future[String], when you method said that you want to return a String.
The request return a Future because it's an asynchronous call.
So, you have two alternatives:
Change your method definition to return a Future[String], and manage this future in another method (with .map())
Force the request to get this result immediately, in a synchronous way. It's not a very good deal, but sometimes it's the simplest solution.
import scala.concurrent.Await
import scala.concurrent.duration.Duration
val response: String = Await.result(req, Duration.Inf)