Realtime updates are kicking my ass! I have my entire fb app working except for this one area and I'm just not sure what I'm doing wrong.
My app is approved using these permissions:
"scope" => "offline_access,publish_stream,read_stream,user_location,user_status",
Next, I subscribe using these settings:
$subscribe = array( 'access_token'=> substr($my_access_token,13),
'object' => 'user',
'fields' => 'name,feed',
'callback_url' => $fbconfig['callback'],
'verify_token' => $fbconfig['secret']);
Via my app I post a status update on behaf of Bill Smith (userid: 000041143) and
that appears on Bill Smith's wall just fine. Next, using a an account for John
Doe (userid: 000004842 which has NOT authorized my app) I comment on the status post
made on Bill Smith's wall and this triggers the callback but what I'm getting (see below)
is an entry telling me that John Doe's wall has changed and no mention of Bill Smiths
wall is ever made.
Here's the notification given in the callback:
updates = Array
(
[object] => user
[entry] => Array
(
[0] => Array
(
[uid] => 000004842
[id] => 000004842
[time] => 1325101631
[changed_fields] => Array
(
[0] => feed
)
)
[1] => Array
(
[uid] => 000004842
[id] => 000004842
[time] => 1325101651
[changed_fields] => Array
(
[0] => feed
)
)
)
)
As you can see, this is not a notification that a comment has been made to Bill Smiths wall but that one has been made to John Doe's... I dont get this... I must be doing SOMETHING wrong!
I had similar issues before with photo IDs turning up 'wrong', the issue occurred because I was treating it as an INT but PHP was truncating it because it was too big, I had to treat it as a string. Could this be your issue perhaps?
Related
I cant seem to find a way with the NgRx (not RxJS Style) to dispatch 2 Actions in an effect.
I would like to (IN THIS ORDER):
delete a Movie in the Database with an effect,
dispatch deleteMovieSuccess
dispatch getMovies (I need to reload all Movies afterwards!)
I tried to do it like below, but it just fires the first Action, and I cannot see the other action:
In my log I can see:
[Movie list] Delete movie
[Movie list] Get movies
[Movie list] Get movies successful
I have the folloing actions:
export const getMovies = createAction('[Movie List] Get Movies', props<{search: string, page: number, limit: number}>());
export const getMoviesSuccess = createAction('[Movies List] Get Movies Success', props<{ search: string, page: number, limit: number }>());
export const deleteMovie = createAction('[Movie List] Remove Movie', props<{ movieToDelete: Movie, search: string, page: number, limit: number }>());
export const deleteMovieSuccess = createAction('[Movie List] Remove Movie Success', props<{ movieToDelete: Movie }>());
and the following effect:
deleteMovie$ = createEffect(() => this.actions$.pipe(
ofType(MovieActions.deleteMovie),
mergeMap(({movieToDelete, search, page, limit}) =>
this.moviesService.deleteMovie(movieToDelete)
.pipe(
map(() => MovieActions.deleteMovieSuccess({movieToDelete: movieToDelete})),
map(() => MovieActions.getMovies({search, page, limit})),
catchError(() => EMPTY)
)
)
)
);
How can I trigger BOTH, deleteMoviesSuccess, and getMovies in this order?
I`ve also tried with switchMap and and faltMap, but never are both Actions dispatched correctly.
I just cant seem to understand, how dispatching in an iterative way is possible, but I really need it for my special usecase.
Any help is greatly appreciated.
You should not dispatch two action in as a result of an effect. Rather dispatch some kind of success action and then react on that in other effects. Read here
You could create a chain of effect:
dispatch delete action
on finish of delete dispatch deleteSuccess action
on deleteSuccess action trigger loadMovies effect
on loadMovies success some set action for a reducer to pick up
deleteMovie$ = createEffect(() => this.actions$.pipe(
ofType(MovieActions.deleteMovie),
mergeMap(({movieToDelete, search, page, limit}) => this.moviesService.deleteMovie(movieToDelete).pipe(
map(() => MovieActions.deleteMovieSuccess({movieToDelete: movieToDelete})),
catchError(() => EMPTY)
))
));
loadMovie$ = createEffect(() => this.actions$.pipe(
ofType(MovieActions.deleteMovieSuccess),
mergeMap(() => this.moviesService.loadMovies().pipe(
map(movies => MovieActions.setMovies({ movies })),
catchError(() => EMPTY)
))
));
EDIT
Also instead of passing parameters like limit or search you may hold these in the store. Doing so gives you the advantage to always access those in effects when needed. The NgRx Documentation has a great example on how this selecting in an effect is done. ngrx.io/api/effects/concatLatestFrom
you could use the switchMap operator to return an array of actions.
For example, instead of;
deleteMovie$ = createEffect(() => this.actions$.pipe(
ofType(MovieActions.deleteMovie),
mergeMap(({movieToDelete, search, page, limit}) =>
this.moviesService.deleteMovie(movieToDelete)
.pipe(
map(() => MovieActions.deleteMovieSuccess({movieToDelete: movieToDelete})),
map(() => MovieActions.getMovies({search, page, limit})),
catchError(() => EMPTY)
)
)
)
);
You could try;
deleteMovie$ = createEffect(() => this.actions$.pipe(
ofType(MovieActions.deleteMovie),
mergeMap(({movieToDelete, search, page, limit}) =>
this.moviesService.deleteMovie(movieToDelete)
.pipe(
switchMap(() => [MovieActions.deleteMovieSuccess({movieToDelete: movieToDelete}),
MovieActions.getMovies({search, page, limit})]),
catchError(() => EMPTY)
)
)
)
);
I have been using Stripe inside my Django project with no problems so far, everything is working, however I am confused about the payment_method parameter. At the moment I have it set to pm_card_visa because that's what the documentation told me to do, however I believe this is causing me problems as when I put in a dummy Mastercard number that Stripe gives you, it is still defaulting to use the default 4242 4242 4242 card.
How can I dynamically set the payment_method variable?
pm_card_visa is a 'shortcut' to the 4242424242424242 test card. You instead need to put in whatever Payment Method ID you get from Elements. https://stripe.com/docs/payments/accept-a-payment
$create = $stripe->paymentIntents->create([
'amount' => 100,
'currency' => 'usd',
'payment_method_types' => ['card'],
]);
$id = $create->id;
$method = $stripe->paymentMethods->create([
'type' => 'card',
'card' => [
'number' => '4242424242424242',
'exp_month' => 12),
'exp_year' => 2022 ),
'cvc' => '314',
],
]);
$payment = $stripe->paymentIntents->confirm(
$id,
['payment_method' => $method]
);
I am using Aws SNS to send notification, and sending notifications to different topics and is working perfectly.
When i publish notification, i got array like
object(Aws\Result)#84 (1) {
["data":"Aws\Result":private]=>
array(2) {
["MessageId"]=>
string(36) "************-7a29-591f-8765-************"
["#metadata"]=>
array(4) {
["statusCode"]=>
int(200)
["effectiveUri"]=>
string(40) "https://sns.ap-southeast-1.amazonaws.com"
["headers"]=>
array(4) {
["x-amzn-requestid"]=>
string(36) "************-b737-5831-abf4-************"
["content-type"]=>
string(8) "text/xml"
["content-length"]=>
string(3) "294"
["date"]=>
string(29) "Fri, 28 Oct 2016 08:59:05 GMT"
}
["transferStats"]=>
array(1) {
["http"]=>
array(1) {
[0]=>
array(0) {}
}
}
}
}
}
I am using php at server side,
But i need to generate a report for each topic separately, that which endpoints (subscriber of topic) get notification and whether notifications are failed, and what is the percentage of successful delivery.
After a lot of research, i found that Aws CloudWatch can do my work, i also searched on stackOverflow for this, and got this answer:
How to confirm delivery status when using amazonSNS mobile push?
I also generated some log in CloudWatch,
By describeLogGroups, i am getting array like
[logGroups] => Array(
[0] => Array
(
[logGroupName] => sns/ap-southeast-1/************/app/GCM/AndroidN
[creationTime] => ************
[retentionInDays] => 30
[metricFilterCount] => 0
[arn] => arn:aws:logs:ap-southeast-1:************:log-group:sns/ap-southeast-1/************/app/GCM/AndroidN:*
[storedBytes] => 3133
)
)
By describeLogStreams, i am getting array like
[logStreams] => Array(
[0] => Array
(
[logStreamName] => 25
[creationTime] => 1477574852344
[firstEventTimestamp] => 1477574831966
[lastEventTimestamp] => 1477574831966
[lastIngestionTime] => 1477574852374
[uploadSequenceToken] => ***********************8
[arn] => arn:aws:logs:ap-southeast-1:*********:log-group:sns/ap-southeast-1/**********/app/GCM/AndroidN:log-stream:25
[storedBytes] => 627
)
)
but confused that how to access it for a particular topic, because in my website i create some topics for group of users (endpoints), and now i want to show for every topic how much notification sent/failed to endpoints not to topic,
Thanks in Anticipants.
I use Facebook Graph API to post on user's wall. I also attach Flash application ("source" parameter) to it.
$data = array(
'name' => 'Test name',
'message' => 'Custom message',
'picture' => 'http://www.example.com/image.png',
'link' => 'http://www.example.com',
'description' => 'Description of the message',
'source' => 'http://www.example.com/flash.swf',
'access_token' => '... token_here ...',
'method' => 'post'
);
$ret = file_get_contents('https://graph.facebook.com/me/feed?'.http_build_query($data));
The problem that i can't set flash size. For example if use REST API, then you can define attached flash size by "expanded_width" and "expanded_height" parameters.
A few month ago when i tried to publish such post i saw that Facebook set flash size to 398x260, but today when i tried it again, i saw that Facebook set size to 398x224.
1) Does someone know if there is some way to define flash size in Graph API, like in REST API?
2) Is there some official documentation that provide default size of post attachment (source)?
I have been trying to read the news feed from a page that I have using an app that I'm coding.
Now I have had some issues trying to do this using the PHP SDK 3.0.
I am able to get the page information, but this is something that is publicly available any way.
My question is how do I get (read) the page wall posts? I'm assuming I have to grant permissions to my app to post to page, but how do I do this?
currently this is the code that I have
$appId = 'XXXXXXXXXXXXXXXXXX';
$secret = 'YYYYYYYYYYYYYYYY';
$pageId = 'ZZZZZZZZZZZZZZZZZZ';
$facebook = new Facebook(array(
'appId' => $appId,
'secret' => $secret
));
$pageProfile = $facebook->api($pageId);
$pagePosts = $facebook->api($pageId . '/posts/');
echo 'My Page profile';
print_r($pageProfile);
echo 'My Page wall';
print_r($userPosts);
Under 'My Page wall' I don't get anything. I don't get any errors either.
To access the posts of a page, it is /feed and not /post. Then, here is the correct version of your example :
require "facebook.php";
$facebook = new Facebook(array(
'appId' => YOUR_APP_ID,
'secret' => YOUR_APP_SECRET,
));
$pageFeed = $facebook->api(THE_PAGE_ID . '/feed');
Then the array $pageFeed will contain the 25 latest posts and links to navigation :
Array(
[data] => Array(
[0] => Array(
[id] => ...
[from] => ...
[to] => ...
[message] => ...
[icon] => ...
[type] => ...
[application] => ...
[created_time] => ...
[updated_time] => ...
)
[1] => ...
[2] => ...
...
[24] => ...
)
[paging] => Array(
[previous] => https://...
[next] => https://...
)
)
Hope that helps !
I know this is old, but I'll bring it up again! I just spent the last three days busting tail and trying to hack and crack the PHP SDK and Graph API, and I've done alright! I posted a full length lab with code and descriptions on my page, and you can view it below and ask me any questions you might have.
Basically, page feed is in a "graph" of info, or a super array. You use the app to connect to the facebook page, and get the feed. Connecting to a page's feed requires no permission from the page, hence why all you need is your APP ID, APP SECRET, and PAGE ID. The SDK automatically generates the APP ACCESS TOKEN for you, so you'r good there.
From then on, it's just about manipulating the graph. I've learned that Facebook feed has different types of posts. some are "photo", "message", "link". Anyways, check out the lab and tell me what you think.
http://www.callmenick.com/labs/displaying-a-custom-facebook-page-feed