ianlee-dev / facebook-java-api

Automatically exported from code.google.com/p/facebook-java-api
0 stars 0 forks source link

Unable to send mail using notifications_sendEmail() method #253

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Hello all,

I am using the facebook-java-api-3.0.0-SNAPSHOT API for my facebook 
application. 

To send mail i am using the below specified code snippet.

-----------
some code here 
-----

            String sessionKey = "<SESSION_KEY>";
            String apiKey = "<API_KEY>";

            String secretKey = "<SECRET_KEY>";

            try {
                FacebookJaxbRestClient client = new 
FacebookJaxbRestClient(apiKey, secretKey, sessionKey);
                boolean appUser = client.users_isAppUser();
                Long userId = 
client.users_getLoggedInUser();
                client.friends_get(uid);
                FriendsGetResponse friendsResp = 
(FriendsGetResponse) client.getResponsePOJO();
                List<Long> friends = friendsResp.getUid();

                Collection<Long> frndList = new 
ArrayList<Long>();

                for (Iterator iterator = 
friends.iterator(); iterator.hasNext();) {
                    Long element = (Long) 
iterator.next();
                    frndList.add(element);
                }
                List<Long> name = 
client.notifications_sendEmail(frndList, "Test email ... ", "test 
mail....", "test mailsss...");
                System.out.println("Email sent to .... ");  
                for (Iterator iterator = name.iterator(); 
iterator.hasNext();) {
                        Long element = (Long) 
iterator.next();

System.out.println(element);
                    }

                } catch (FacebookException e) {
                System.err.println(e.getMessage());
                e.printStackTrace();
            }

-------- 
some other code here 
------

But my trace shows a class cast exception from the line 

List<Long> name = client.notifications_sendEmail(frndList, "Test email ... 
", "test mail....", "test mailsss...");

------------------------------------------
The trace details are as follows...
------------------------------------------
java.lang.ClassCastException: javax.xml.bind.JAXBElement
    at 
com.google.code.facebookapi.FacebookJaxbRestClient.notifications_sendEmail(
FacebookJaxbRestClient.java:194)
    at 
com.daffodilsw.dak.facebook.FacebookServlet.doGet(FacebookServlet.java:121)
    at 
com.daffodilsw.dak.facebook.FacebookServlet.doPost(FacebookServlet.java:185
)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applicatio
nFilterChain.java:290)
    at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterC
hain.java:206)
    at 
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.j
ava:233)
    at 
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.j
ava:175)
    at 
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:12
8)
    at 
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:10
2)
    at 
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.jav
a:109)
    at 
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
    at 
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
    at 
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Htt
p11Protocol.java:583)
    at 
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    at java.lang.Thread.run(Thread.java:595)

Kindly suggest how to resolve this problem, I am unable to send mail.....

Sagar

Original issue reported on code.google.com by sagarhas...@gmail.com on 15 Oct 2009 at 4:50